Skip to content

Conversation

@yulin-li
Copy link
Contributor

@yulin-li yulin-li commented Sep 20, 2022

Description

got ZeroDevisionError

Callback failed for instrument system.swap.utilization.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/opentelemetry/sdk/metrics/_internal/instrument.py", line 132, in callback
    for api_measurement in callback(callback_options):
  File "/usr/local/lib/python3.8/dist-packages/opentelemetry/instrumentation/system_metrics/__init__.py", line 515, in _get_system_swap_utilization
    getattr(system_swap, metric) / system_swap.total,
ZeroDivisionError: division by zero

Fixes #1337

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@yulin-li yulin-li requested a review from a team September 20, 2022 14:21
@yulin-li yulin-li changed the title avoid devidedByZero exception when sawp memory is 0 avoid ZeroDevisionError exception when swap memory is 0 Sep 20, 2022
@lzchen lzchen added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Sep 20, 2022
@yulin-li
Copy link
Contributor Author

could we get this merged? @lzchen

@lzchen
Copy link
Contributor

lzchen commented Sep 26, 2022

@yulin-li
Please fix build issues.

@yulin-li
Copy link
Contributor Author

@yulin-li Please fix build issues.

I believe I fixed the lint issue and verified using python scripts/eachdist.py lint locally.

@ocelotl ocelotl merged commit 9d8228f into open-telemetry:main Sep 27, 2022
@yulin-li yulin-li deleted the yulin/zero branch September 27, 2022 18:15
saartochner-lumigo pushed a commit to lumigo-io/opentelemetry-python-contrib that referenced this pull request Nov 13, 2022
…ry#1345)

* avoid devidedByZero exception when sawp memory is 0

* lint

Co-authored-by: Srikanth Chekuri <[email protected]>
saartochner-lumigo pushed a commit to lumigo-io/opentelemetry-python-contrib that referenced this pull request Nov 13, 2022
…ry#1345)

* avoid devidedByZero exception when sawp memory is 0

* lint

Co-authored-by: Srikanth Chekuri <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting ZeroDivisionError in Swap Utilization

4 participants