client_python
client_python copied to clipboard
Multiprocess mode support for 'remove'
In multiprocess mode calling 'remove' on a metric/label doesn't actually remove it from the metrics output.
Also, because of the disconnect between the Metric classes's remove and MultiProcessValue, the following snippet will use more memory every iteration as the MultiProcessValue.values list keeps adding copies.
import os
os.environ['PROMETHEUS_MULTIPROC_DIR'] = '/tmp'
from prometheus_client import Counter
c = Counter('a', 'a', ['a'])
while True:
c.labels('hi').inc()
c.remove('hi')
Perhaps 'remove' should be disabled in multiprocess mode, or at least something added to the multiprocess documentation?