Closed Cellebyte closed 4 years ago
Find a solution to remove the memory issue.
from prometheus_client.core import CounterMetricFamily
c = CounterMetricFamily('my_counter_total', 'Help text', labels=['foo'])
c.add_metric(['bar'], 1.7)
c.add_metric(['baz'], 3.8)
yield c
# this is important if you reuse the *MetricFamily
c.samples.clear()
Hey All,
I have an interesting memory leak inside prometheus_client. I am using the CollectorRegistry and added Collectors to it for getting metrics of devices which do not support the OpenMetrics Endpoint.
Using the current version 0.7.1 with python 3.7.3 on a debian buster I am running into constantly increasing memory on my host.
The offending line is eg.:
https://github.com/prometheus/client_python/blob/3ab0374d1548769748932b9316d86b088dc7712e/prometheus_client/metrics_core.py#L77-L83
I don't know why the samples are always referenced.
Trace information: