Handle exceptions when cpu_total is zero#611
Conversation
|
Hmm, as far as I can tell there are no non-standard requirements to run those tests. Did you install the base test requirements? If so, what error are you seeing when you try to run those tests? |
|
@basepi no errors were thrown, the tests from Just added a simple test that exposes |
beniwohli
left a comment
There was a problem hiding this comment.
just a little detail in the tests, other than that LGTM! Thanks for the PR!!
tests/metrics/cpu_linux_tests.py
Outdated
| data = next(metricset.collect()) | ||
|
|
||
| cpu_total_expected = 0 | ||
| assert data["samples"]["system.cpu.total.norm.pct"]["value"] == cpu_total_expected No newline at end of file |
There was a problem hiding this comment.
How about also asserting on system.process.cpu.total.norm.pct being 0 here?
There was a problem hiding this comment.
Makes sense! Thanks for the tip
tests/metrics/cpu_linux_tests.py
Outdated
|
|
||
| cpu_total_expected = 0 | ||
| assert data["samples"]["system.cpu.total.norm.pct"]["value"] == cpu_total_expected | ||
| assert data["samples"]["system.process.cpu.total.norm.pct"]["value"] == cpu_total_expected No newline at end of file |
There was a problem hiding this comment.
I think the lack of a newline at the end of the file is why you're seeing linting errors. That said, we really need to improve the lint output because it's not obvious at all.
There was a problem hiding this comment.
Right, let's see if the update helps
|
@ivasic I released 5.2.2 with this fix: https://github.com/elastic/apm-agent-python/releases/tag/v5.2.2 Thank you again for the contribution! |
Ref #610
I wasn't able to run tests from
cpu_linux_test.pyfor some reason, if anyone is willing to help with that I can include a simple test as well.