prometheus / prometheus/client_python

Multiprocess mode support for 'remove'

Open
#720 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.4k
Forks
876
Avg merge
8d 4h
Merged PRs (30d)
1

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided loop in multiprocess mode, then inspect the Metric classes' remove behavior alongside MultiProcessValue and the multiprocess documentation. Determine how removal should affect emitted metrics and the growing values list; done means the chosen behavior is implemented and covered by a regression test, or the limitation is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.