You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into an issue when creating an exception counter out of a standard counter without passing label names. Specifically, it does not provide an informative error if a user incorrectly passes labels when calling count_exceptions. Code to replicate:
from prometheus_client import Counter
c = Counter('counter', documentation='A sample counter', labelnames=('label',))
with c.count_exceptions():
raise RuntimeError('panic!')
Expected behavior: c.count_exceptions() should raise an informative error message because the incorrect labels are passed.
Actual behavior: AttributeError: 'Counter' object has no attribute '_value' occurs when the exception is raised, because we are trying to increment an non observable metric.
Proposed fix: Check self._is_observable() in the count_exceptions method, and raise an error if the user is constructing an ExceptionCounter out of a non observable Counter.
Activity
brian-brazil commentedon Aug 19, 2019
Do you want to send a PR?
AlexPadron commentedon Aug 19, 2019
sure!
AlexPadron commentedon Aug 19, 2019
I think I need access to the repo, not currently able to push to a remote branch
brian-brazil commentedon Aug 19, 2019
Fork it in github, and push your branch there.
AlexPadron commentedon Aug 19, 2019
#455