-
Notifications
You must be signed in to change notification settings - Fork 845
'Counter' object has no attribute '_value' #454
Copy link
Copy link
Closed
Description
Hi all,
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels