klio.metrics.logger
Klio ships with a default klio.metrics.base.AbstractRelayClient implementation, which outputs metrics via the standard library logging module through the MetricsLoggerClient below.
klio.metrics.base.AbstractRelayClient
logging
MetricsLoggerClient
This implementation is used by default if no other metrics consumers are configured. It must be explicitly turned off.
The default configuration in klio-info.yaml can be overwritten:
klio-info.yaml
job_config: metrics: logger: # Logged metrics are emitted at the `debug` level by default. level: info # Default timer unit is ns/nanoseconds; available # options include `s` or `seconds`, `ms` or `milliseconds`, # `us` or `microseconds`, and `ns` or `nanoseconds`. timer_unit: s
To turn off logging-based metrics:
job_config metrics: logger: false
klio.metrics.logger.
TIMER_UNIT_MAP
Map of supported measurement units to shorthand for LoggerTimer.
LoggerTimer
Logging client for transform metrics.
Intended to be instantiated by klio.metrics.client.MetricsRegistry and not by itself.
klio.metrics.client.MetricsRegistry
klio_config (klio_core.config.KlioConfig) – the job’s configuration.
disabled (bool) – whether or not to disable the Python logger Default: False.
logger
False
Python logger associated with the job which this client will use to emit metrics.
unmarshal
Return a dict-representation of a given metric.
metric (LoggerMetric) – logger-specific metrics object
metric data
dict(str, str)
emit
Log a given metric.
counter
Create a LoggerCounter object.
LoggerCounter
name (str) – name of counter
value (int) – starting value of counter; defaults to 0
transform (str) – transform the counter is associated with
tags (dict) – any tags of additional contextual information to associate with the counter
a log-based counter
gauge
Create a LoggerGauge object.
LoggerGauge
name (str) – name of gauge
value (int) – starting value of gauge; defaults to 0
transform (str) – transform the gauge is associated with
tags (dict) – any tags of additional contextual information to associate with the gauge
a log-based gauge
timer
Create a LoggerTimer object.
name (str) – name of timer
value (int) – starting value of timer; defaults to 0
transform (str) – transform the timer is associated with
tags (dict) – any tags of additional contextual information to associate with the timer
timer_unit (str) – timer unit; defaults to configured value in klio-job.yaml, or “ns”. See module-level docs of klio.metrics.logger for supported values.
a log-based timer
LoggerMetric
Base metric type for loggers.
value (int) – initial value. Default: 0.
0
transform (str) – Name of transform associated with metric, if any.
tags (dict) – Tags to associate with metric.
Log-based counter metric.
transform (str) – Name of transform associated with counter, if any.
tags (dict) – Tags to associate with counter. Note: {"metric_type": "counter"} will always be an included tag.
{"metric_type": "counter"}
Log-based gauge metric.
transform (str) – Name of transform associated with gauge, if any.
tags (dict) – Tags to associate with gauge. Note: {"metric_type": "gauge"} will always be an included tag.
{"metric_type": "gauge"}
Log-based timer metric.
transform (str) – Name of transform associated with timer, if any.
tags (dict) – Tags to associate with timer. Note: {"metric_type": "timer"} will always be an included tag.
{"metric_type": "timer"}
timer_unit (str) – Unit of measurement. Options: TIMER_UNIT_MAP. Default: ns (nanoseconds).
ns