Skip to content

Guidance to avoid duplicate metrics in multiprocess - #651

Merged
csmarchbanks merged 1 commit into
masterfrom
clarify-multiprocess-registry-use
May 14, 2021
Merged

csmarchbanks merged 1 commit into
masterfrom
clarify-multiprocess-registry-use

Conversation

@csmarchbanks

Copy link
Copy Markdown
Member

Closes #647

Comment thread README.md
This comes with a number of limitations:

- Registries can not be used as normal, all instantiated metrics are exported
- Registering metrics to a registry later used by a `MultiProcessCollector`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is under a section called (Gunicorn) however this seems more generic and not tied to Gunicorn, right? I hit this issue with UWSGI.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also begs the question of, what is the case someone does want to register a metric to a registry?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Gunicorn specification is a good point, perhaps (E.g. Gunicorn) instead to make it clear that is an example?

There are lots of valid use cases to register a metric when in non-multiprocess mode, it just doesn't work for multi-process right now. For example, when building a custom exporter you might have one registry for internal metrics, and a second registry for the metrics coming from something being probed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roger that

Comment thread README.md Resolved
Signed-off-by: Chris Marchbanks <csmarchbanks@gmail.com>
@csmarchbanks
csmarchbanks force-pushed the clarify-multiprocess-registry-use branch from 933f763 to 6d572df Compare May 13, 2021 22:31
Comment thread README.md
There's several steps to getting this working:

**1. Gunicorn deployment**:
**1. Deployment**:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread README.md
from prometheus_client import generate_latest, CollectorRegistry, CONTENT_TYPE_LATEST
from prometheus_client import generate_latest, CollectorRegistry, CONTENT_TYPE_LATEST, Counter

MY_COUNTER = Counter('my_counter', 'Description of my counter')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@csmarchbanks
csmarchbanks merged commit 6df81ae into master May 14, 2021
@csmarchbanks
csmarchbanks deleted the clarify-multiprocess-registry-use branch May 14, 2021 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

multiprocess in uwsgi leads generate_latest to sometimes contain duplicates

2 participants