Changes

Jump to: navigation, search

CloudServices/Sagrada/Metlog

158 bytes removed, 20:06, 6 October 2011
no edit summary
We will provide a "metlog" library that will both ease generation of these messages and that will handle packaging them up and delivering them (via UDP) into the message processing infrastructure. Implementations of this library will likely be available in both Python and Javascript, but the Python library will be available first and this document will, for now, only describe the Python API. The Javascript API will be similar, modulo syntactic sugar that is available in Python but not in JS (e.g. decorators, context managers), and will be documented in detail in the future. The proposed Python API is as follows:
; '''set_metlog_destMetlogClient(host, port, logger="", severity=6)''' : Specifies Primary metlog client class which can accept metlog messages and will deliver them to the address message processor listening at the specified ''host'' and ''port of the metlog listener, the destination of the UDP packets that ''. The provided ''logger'' and ''severity'' values will be sent out as a result of used by default for all subsequent ''metlog'' method calls. The Services Python framework will provide a mechanism to specify this via configuration files so services authors won't have to make this call themselveswhich do not explicitly pass other values.
; '''set_default_loggerMetlogClient.set_message_flavor(loggerflavor_name, metadata)''' : Specifies The metadata for a given message can be used to label and categorize that message. This method expects a logger string value ''flavor_name'' and a dictionary ''metadata''. The flavor name value can be passed in as a ''flavor'' to use as the default for all subsequent ''metlog'' calls as shorthand for including the specified metadata in which a logger value is not explicitly providedthe outgoing message.
; '''set_message_flavorMetlogClient.metlog(flavor_nametimestamp=None, logger=None, severity=None, message="", metadata=None, flavors=None)''' : The metadata for Sends a given single log message can be used to label and categorize that messagethe previously specified metlog listener. This function expects a string value ''flavor_name'' and a dictionary ''metadata''. The flavor name value can be passed in as a ''flavor'' Most of the arguments correspond to subsequent ''metlog'' calls as shorthand for including the specified metadata in the outgoing messagefields described above.None of them are strictly required, but most of them will be populated by reasonable defaults if they aren't provided:
; '''metlog(timestamp=None, logger=None, severity=6, message="", metadata=None, flavors=None)''' : Sends a single log message to the previously specified metlog listener. Most of the arguments correspond to the message fields described above. None of them are strictly required, but most of them will be populated by reasonable defaults if they aren't provided: * ''timestamp'': Defaults to current system time.* ''logger'': Defaults to what has been specified using the ''set_default_logger'' call, or to an empty string if ''set_default_logger'' hasn't been calledcurrent value of MetlogClient.logger* ''severity'': Defaults to 6 ("Informational")the current value of MetlogClient.severity
* ''message'': Defaults to an empty string
* ''metadata'': Defaults to an empty dictionary
* ''flavors'': Any specified flavors will cause this message's metadata value to be updated to contain the flavor's metadata; defaults to an empty list
; '''MetlogClient.timer(name, timestamp=None, logger=None, severity=6None, metadata=None, flavors=None, rate=1)''' : Can be used as either a context manager or a decorator. Will calculate the time required to execute the enclosed code, and will generate and send a metlog message containing the timing information upon completion. ''name'' is a required string label for the timer that will be added to the message metadata. ''rate'' represents what fraction of these invocations should actually be timed, so a value of 0.3 would mean that the code would be timed and the results sent off approximately 30% of the time it was executed.
; '''MetlogClient.incr(name, timestamp=None, logger=None, severity=6None, metadata=None, flavors=None)''' : Sends an "increment counter" message to metlog. ''name'' is a required string label for the counter that will be added to the message metadata.
== Use Cases ==
Confirm
125
edits

Navigation menu