Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[question] Why default collectors implementations create metric object every time when #collect methos is called #1120

Unanswered
sleshJdev asked this question in Q&A
Discussion options

https://github.com/prometheus/client_python/blob/master/prometheus_client/gc_collector.py

Should default collectors re-use already created instance of metric? Why it creates it again and again?

You must be logged in to vote

Replies: 1 comment

Comment options

It's not much work to create new instances of the metric and allows the collector itself not to keep any state or locking logic. Not applicable to the gc collector specifically, but the pattern of recreating all metrics also makes sure that old values are not kept forever when an underlying resource is deleted.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #1119 on July 29, 2025 21:01.

AltStyle によって変換されたページ (->オリジナル) /