klio.metrics.client
Metrics registry to manage metrics for all configured relay clients.
The MetricsRegistry class is the main client for which to create and emit metrics. For example:
MetricsRegistry
class MyTransform(KlioBaseTransform): def __init__(self): self.my_counter = self._klio.metrics.counter( name="foo", value=2, transform="mytransform", tags={"tag1": "value1"} ) def process(self, element): # user code # immediately emits a metric self.my_counter.inc()
klio.metrics.client.
Main client to create and emit metrics.
relay_clients (list(klio.metrics.base.AbstractRelayClient)) – configured relay clients.
counter
Get or create a counter.
Creates a new counter if one is not found with a key of "counter_{name}_{transform}" of the given transform.
"counter_{name}_{transform}"
transform
New counters will be stored in memory for simple caching.
name (str) – name of counter
value (int) – starting value of counter; defaults to 0
kwargs (dict) – keyword arguments passed to each configured relay clients’ counter object.
instance of a counter dispatcher
dispatcher.CounterDispatcher
gauge
Get or create a gauge.
Creates a new gauge if one is not found with a key of “gauge_{name}_{transform}”.
New gauges will be stored in memory for simple caching.
name (str) – name of gauge
value (int) – starting value of gauge; defaults to 0
kwargs (dict) – keyword arguments passed to each configured relay clients’ gauge object.
instance of a gauge dispatcher
dispatcher.GaugeDispatcher
timer
Get or create a timer.
Creates a new timer if one is not found with a key of “timer_{name}_{transform}”.
New timers will be stored in memory for simple caching.
name (str) – name of timer
value (int) – starting value of timer; defaults to 0
timer_unit (str) – desired unit of time; defaults to ns
kwargs (dict) – keyword arguments passed to each configured relay clients’ timer object.
instance of a timer dispatcher
dispatcher.TimerDispatcher
marshal
Create a dictionary-representation of a given metric.
Used when metric objects need to be pickled.
metric (dispatcher.BaseMetricDispatcher) – metric instance to marshal.
the metric’s data in dictionary form
dict
unmarshal
Create a metric instance based off of a dictionary.
If “type” is not specified or is not one of “counter”, “gauge”, or “timer”, it defaults to a gauge-type metric.
Used when metrics objects need to be unpickled.
metric_data (dict) – dictionary-representation of a given metric.
a dispatcher relevant to metric type.
dispatcher.BaseMetricDispatcher