1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
---
title: Histogram
weight: 4
---
Histograms track the size and number of events in buckets.
This allows for aggregatable calculation of quantiles.
```python
from prometheus_client import Histogram
h = Histogram('request_latency_seconds', 'Description of histogram')
h.observe(4.7) # Observe 4.7 (seconds in this case)
```
The default buckets are intended to cover a typical web/rpc request from milliseconds to seconds.
They can be overridden by passing `buckets` keyword argument to `Histogram`.
There are utilities for timing code:
```python
@h.time()
def f():
pass
with h.time():
pass
```
|