10000 'Counter' object has no attribute '_value' · Issue #454 · prometheus/client_python · GitHub
[go: up one dir, main page]

Skip to content

'Counter' object has no attribute '_value' #454

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

Closed
AlexPadron opened this issue Aug 19, 2019 · 5 comments
Closed

'Counter' object has no attribute '_value' #454

AlexPadron opened this issue Aug 19, 2019 · 5 comments

Comments

@AlexPadron
Copy link
Contributor

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.

@brian-brazil
Copy link
Contributor

Do you want to send a PR?

@AlexPadron
Copy link
Contributor Author

sure!

@AlexPadron
Copy link
Contributor Author

I think I need access to the repo, not currently able to push to a remote branch

@brian-brazil
Copy link
Contributor

Fork it in github, and push your branch there.

@AlexPadron
Copy link
Contributor Author

#455

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

No branches or pull requests

2 participants
0