client_python icon indicating copy to clipboard operation
client_python copied to clipboard

Multiprocess mode support for 'remove'

Open darintay opened this issue 4 years ago • 0 comments

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?

darintay avatar Nov 07 '21 07:11 darintay