Summary is a metric that captures individual observations and tracks the total size & number of events observed. It can be useful to track latencies for example.
When scraped a summary produces a couple of time series:
- total sum of observed values (ex.
- count of events that have been observed (ex.
For when to use a summary vs histograms check the prometheus docs
Observe a value
To observe a value you can call the
You can track time with the
time() context manager, it will track the duration in seconds:
As a Decorator
When used as a decorator the
Summary will time the piece of code, syntactic sugar to the
time() context manager: