Changes

Jump to: navigation, search

CloudServices/Sagrada/Metlog

159 bytes added, 01:08, 19 October 2011
no edit summary
* ''severity'': Numerical code from 0-7 indicating the severity of the message, as defined by [https://tools.ietf.org/html/rfc5424 RFC 5424].
* ''payload'': Actual message contents.
* ''tagsfields'': Arbitrary set of key/value pairs that includes any additional data that may be useful for back end reporting or analysis.* ''env_version'': API version number of the "message envelope", i.e. any changes to the message data structure (exclusive of message-type-specific changes that may be embedded within the tags fields or the payload) must increment the env_version value. The structure described in this document is envelope version 0.8.
We will provide a "metlog" library that will both ease generation of these messages and that will handle packaging them up and delivering them 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:
; '''MetlogClient(bindstrssender, logger="", severity=6)''' : Primary metlog client class which can accept metlog messages , format and serialize them, and will deliver pass them along for delivery to the message processor.
* ''bindstrssender'': A string (or "sender" object, i.e. any object that exposes a sequence of strings) representing ''send_message'' method accepting a single ''msg'' argument. All actual message transport and delivery is the location responsibility of the upstream message processorsender. By default these should be We will provide a ZeroMQ bind stringsPublisher sender implementation.
* ''logger'': Default for all subsequent ''metlog'' calls which do not explicitly pass this value.
* ''severity'': Default for all subsequent ''metlog'' calls which do not explicitly pass this value.
; '''MetlogClient.metlog(type, timestamp=None, logger=None, severity=None, message="", tagsfields=None)''' : Sends a single log message along to the metlog listener(s). Most of the arguments correspond to the message fields described above. Only ''type'' is strictly required, the rest will be populated by reasonable defaults if they aren't provided:
* ''timestamp'': Defaults to current system time
* ''severity'': Defaults to the current value of MetlogClient.severity
* ''message'': Defaults to an empty string
* ''tagsfields'': Defaults to an empty dictionary
; '''MetlogClient.timer(name, timestamp=None, logger=None, severity=None, tagsfields=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 (of type "timer") containing the timing information upon completion.
* ''name'': A required string label for the timer that will be added to the message tagsfields
* ''timestamp'': Defaults to current system time
* ''logger'': Defaults to the current value of MetlogClient.logger
* ''severity'': Defaults to the current value of MetlogClient.severity
* ''tagsfields'': Defaults to an empty dictionary
* ''rate'' Represents what fraction of these invocations should actually be timed; 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=None, tagsfields=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.
* ''name'': A required string label for the counter that will be added to the message tagsfields
* ''timestamp'': Defaults to current system time
* ''logger'': Defaults to the current value of MetlogClient.logger
* ''severity'': Defaults to the current value of MetlogClient.severity
* ''tagsfields'': Defaults to an empty dictionary
== Use Cases ==
Confirm
125
edits

Navigation menu