How to clear `Summary` metric value in Python Prometheus client

665 views Asked by At

I'm using Prometheus Python client here. How do you clear a Summary metric without any labels? Example

metric = Summary("test_summary", "")
metric.observe(10)
# Do something
metric.clear()

The last line throws the following error:

self = prometheus_client.metrics.Summary(test_metric)

    def clear(self) -> None:
        """Remove all labelsets from the metric"""
>       with self._lock:
E       AttributeError: 'Summary' object has no attribute '_lock'

../../anaconda3/envs/testenv/lib/python3.10/site-packages/prometheus_client/metrics.py:204: AttributeError
0

There are 0 answers