Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client should automatically initialize label-less metrics to 0 #208

Closed
dmagliola opened this issue Dec 2, 2020 · 1 comment
Closed

Client should automatically initialize label-less metrics to 0 #208

dmagliola opened this issue Dec 2, 2020 · 1 comment

Comments

@dmagliola
Copy link
Collaborator

dmagliola commented Dec 2, 2020

We provide the init_label_set method to deal with the "Missing Metrics" problem on metrics that have labels.
However, we should automatically initialize the empty labelset for metrics that don't take any labels, so a 0 is exported.

A caller could call init_label_set({}), but it's unintuitive, and the Prometheus documentation itself sets the expectation that this will be done for you.

Q: Is this a patch, minor or major?
On the one hand, this is kind of a bug fix. We should've done this when we introduced init_label_set
On the other hand, this is definitely going to affect the output of a client, which may surprise some folk, so it may count as a breaking change. But... It's making that output "more correct". I'm not entirely sure here.

Q: We should 100% do this for counters. Should we also do it for Gauges, etc?
I'd take a cue from the Python/Go clients, do the same they do.
NB: If i'm reading the code correctly, the Python library does this, by calling _metric_init for is_observable metrics, which includes label-less ones, and those with pre-set label values.

@Sinjo
Copy link
Member

Sinjo commented Mar 24, 2021

Fixed by #209

@Sinjo Sinjo closed this as completed Mar 24, 2021
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

No branches or pull requests

2 participants