Skip to content

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

Description

@dmagliola

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions