-
Notifications
You must be signed in to change notification settings - Fork 801
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
Add observability check to counters #455
Add observability check to counters #455
Conversation
Signed-off-by: AlexPadron <alexp@kensho.com>
63d0475
to
38cd675
Compare
prometheus_client/metrics.py
Outdated
# metric is observable will the value be initialized. | ||
if not self._is_observable(): | ||
raise ValueError( | ||
'%s metric is not observable. This is likely because the metric requires ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking if we want to make this more detailed, for example we could use inspect and get the method name that is being invoked. Also, we may want to use this in other metrics as well. I added the check to counters, but the same issue exists in gauges as well for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure "observable" is the right word to use here, it'll confuse users. Missing label values would be more accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other metric types also have helper methods that'd benefit from this.
prometheus_client/metrics.py
Outdated
# metric is observable will the value be initialized. | ||
if not self._is_observable(): | ||
raise ValueError( | ||
'%s metric is not observable. This is likely because the metric requires ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure "observable" is the right word to use here, it'll confuse users. Missing label values would be more accurate.
4971346
to
09c7835
Compare
Signed-off-by: AlexPadron <alexp@kensho.com>
Other metrics types also need this, e.g. the time() functions. |
Signed-off-by: AlexPadron <alexp@kensho.com>
beba64a
to
4c89979
Compare
I think I got all of these (at least in metrics.py). As far as I can tell by grepping this is the only location where the metrics are defined |
Thanks! |
This is for issue #454