klio.metrics.base
Base classes from which a metrics consumer (i.e. ffwd, logger, etc.) will need to implement.
New consumers are required to implement the AbstractRelayClient, and three metrics objects based off of BaseMetric: a counter, a gauge, and a timer.
AbstractRelayClient
BaseMetric
klio.metrics.base.
abstract_attr
Set an attribute or a property as abstract.
Supports class-level attributes as well as methods defined as a @property.
@property
Usage:
class Foo(object): my_foo_attribute = abstract_attr() @property @abstract_attr def my_foo_property(self): pass
obj (callable) – Python object to “decorate”, i.e. a class method. If none is provided, a dummy object is created in order to attach the __isabstractattr__ attribute (similar to __isabstractmethod__ from abc.abstractmethod).
__isabstractattr__
__isabstractmethod__
abc.abstractmethod
Returns object with __isabstractattr__ attribute set to True.
True
Abstract base class for all metric consumer relay clients.
Each new consumer (i.e. ffwd, logging-based metrics) will need to implement this relay class.
RELAY_CLIENT_NAME
must match the key in klio-job.yaml under job_config.metrics.
klio-job.yaml
job_config.metrics
str
unmarshal
Returns a dictionary-representation of the metric object
metric
emit
Emit the given metric object to the particular consumer.
emit will be run in a threadpool separate from the transform, and any errors raised from the method will be logged then ignored.
counter
Return a newly instantiated counter-type metric specific for the particular consumer.
Callers to the counter method will store new counter objects returned in memory for simple caching.
gauge
Return a newly instantiated gauge-type metric specific for the particular consumer.
Callers to the gauge method will store new gauge objects returned in memory for simple caching.
timer
Return a newly instantiated timer-type metric specific for the particular consumer.
Callers to the timer method will store new timer objects returned in memory for simple caching.
Base class for all metric types.
A consumer must implement a counter metric, a gauge metric, and a timer metric.