Skip to content

Fix system metrics unit tests on mac #3638

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

david-gang
Copy link

Description

The system metrics tests on mac are failing:

tox -e py312-test-instrumentation-system-metrics -- -ra

>       self.assertEqual(sorted(metric_names), sorted(observer_names))
E       AssertionError: Lists differ: ['pro[588 chars]work.dropped_packets', 'system.network.errors'[114 chars]unt'] != ['pro[588 chars]work.connections', 'system.network.dropped_pac[144 chars]unt']
E       
E       First differing element 20:
E       'system.network.dropped_packets'
E       'system.network.connections'
E       
E       Second list contains 1 additional elements.
E       First extra element 27:
E       'system.thread_count'
E       
E       Diff is 872 characters long. Set self.maxDiff to None to see it.

instrumentation/opentelemetry-instrumentation-system-metrics/tests/test_system_metrics.py:141: AssertionError

The issue is easy to understand

if sys.platform == "darwin":
    # see https://github.com/giampaolo/psutil/issues/1219
    _DEFAULT_CONFIG.pop("system.network.connections")

But in the unit tests this metric is still tested.
Fixes # (issue)

Type of change

Skip the check of this metric on mac
Please delete options that are not relevant.

  • [V ] 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?

Run Unit test on mac and see that everything passes

tox -e py312-test-instrumentation-system-metrics -- -ra

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • [V ] No.

Checklist:

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

  • [ V] Followed the style guidelines of this project
  • Changelogs have been updated - No changelog to update
  • Unit tests have been added - Just needed to skip one
  • Documentation has been updated - Nothing to update. i just skip a fix

@david-gang david-gang changed the title format Fix system metrics unit tests on mac Jul 13, 2025
Don't test for system.network.connections on mac
@david-gang david-gang force-pushed the fix_system_metrics branch from 534d3b2 to 57cdd2a Compare July 13, 2025 05:56
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

Successfully merging this pull request may close these issues.

1 participant