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

No error on missing labels for Gauge.set_function() #665

Closed
pietrodn opened this issue Jun 9, 2021 · 0 comments · Fixed by #666
Closed

No error on missing labels for Gauge.set_function() #665

pietrodn opened this issue Jun 9, 2021 · 0 comments · Fixed by #666

Comments

@pietrodn
Copy link
Contributor

pietrodn commented Jun 9, 2021

If I try to assign a function to a Gauge using set_function(), the Prometheus library does not error even if the labels are missing.

This code should error, but it does not:

import prometheus_client

processed_input_messages = prometheus_client.Gauge(
    name="my_gauge",
    documentation="A generic Gauge.",
    labelnames=["a", "b"],
)

if __name__ == '__main__':
    # This should fail, because the "a" and "b" labels are not provided!
    processed_input_messages.set_function(lambda: 1)

In general, it would be important to check, for every metric type, if all the labels are set when calling .set(), .inc(), .set_function(), and the other similar metrics.

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 a pull request may close this issue.

1 participant