Metrics API¶
To follow the metrics protocol objects must be iterable repeatedly and yield
(name, value, tags)
-triples, where name
is a string, value
is a float or int,
and tags
is a dict with string keys and values.
-
class
lymph.core.monitoring.metrics.
Metric
(name, tags=None)¶ An abstract base class for single series metrics, i.e. metric objects that only yield a single triple.
-
__iter__
()¶ [abstract] Yields metric values as a tuple in the form (name, value, tags).
-
-
class
lymph.core.monitoring.metrics.
Gauge
(name, value=0, tags=None)¶ A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.
-
set
(value)¶
-
-
class
lymph.core.monitoring.metrics.
Callable
(name, func, tags=None)¶ Like a Gauge metric, but its value is determined by a callable.
-
class
lymph.core.monitoring.metrics.
Counter
(name, tags=None)¶ A counter is a cumulative metric that represents a single numerical value that only ever goes up. A counter is typically used to count requests served, tasks completed, errors occurred, etc.
-
__iadd__
(value)¶ Increment counter value.
-
-
class
lymph.core.monitoring.metrics.
TaggedCounter
(name, tags=None)¶ A tagged counter is a container metric that represents multiple counters per tags. A tagged counter is typically used to track a group of counters as one e.g. request served per function name, errors ocurred per exception name, etc.
-
incr
(_by=1, **tags)¶ Increment given counter
type
by_by
.
-
-
class
lymph.core.monitoring.metrics.
Aggregate
(metrics=(), tags=None)¶ Parameters: - metrics – iterable of metric objects
- tags – dict of tags to add to all metrics.
Aggregates a collection of metrics into a single metrics object.
-
add
(metric)¶ Parameters: metric – metric object Adds the given metric to collection.
Parameters: tags – string-valued dict Adds the given tags for all metrics.