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.
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.
I'm not sure "observable" is the right word to use here, it'll confuse users. Missing label values would be more accurate.
brian-brazil
left a comment
There was a problem hiding this comment.
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.
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