Bases: object
A counter decorator and context manager.
This metric type increments a counter every time the decorated method or context manager is executed. It is bound to this MetricLogger. For example:
from ironic_lib import metrics_utils
METRICS = metrics_utils.get_metrics_logger()
@METRICS.counter('foo')
def foo(bar, baz):
print bar, baz
with METRICS.counter('foo'):
do_something()
Bases: object
A gauge decorator.
This metric type returns the value of the decorated method as a metric every time the method is executed. It is bound to this MetricLogger. For example:
from ironic_lib import metrics_utils
METRICS = metrics_utils.get_metrics_logger()
@METRICS.gauge('foo')
def add_foo(bar, baz):
return (bar + baz)
Bases: object
Abstract class representing a metrics logger.
A MetricLogger sends data to a backend (noop or statsd). The data can be a gauge, a counter, or a timer.
Get the full metric name.
Parameters: | name – The metric name. |
---|---|
Returns: | The full metric name, with logger prefix, as a string. |
Send counter metric data.
Counters are used to count how many times an event occurred. The backend will increment the counter ‘name’ by the value ‘value’.
Optionally, specify sample_rate in the interval [0.0, 1.0] to sample data probabilistically where:
P(send metric data) = sample_rate
If sample_rate is None, then always send metric data, but do not have the backend send sample rate information (if supported).
Parameters: |
|
---|
Send gauge metric data.
Gauges are simple values. The backend will set the value of gauge ‘name’ to ‘value’.
Parameters: |
|
---|
Bases: ironic_lib.metrics.MetricLogger
Noop metric logger that throws away all metric data.
Bases: object
A timer decorator and context manager.
This metric type times the decorated method or code running inside the context manager, and emits the time as the metric value. It is bound to this MetricLogger. For example:
from ironic_lib import metrics_utils
METRICS = metrics_utils.get_metrics_logger()
@METRICS.timer('foo')
def foo(bar, baz):
print bar, baz
with METRICS.timer('foo'):
do_something()