Skip to content

fix(tests): Fix flaky OTel propagator entry point test#6655

Open
ericapisani wants to merge 3 commits into
masterfrom
ep/flaky-propagator
Open

fix(tests): Fix flaky OTel propagator entry point test#6655
ericapisani wants to merge 3 commits into
masterfrom
ep/flaky-propagator

Conversation

@ericapisani

@ericapisani ericapisani commented Jun 24, 2026

Copy link
Copy Markdown
Member

Related flaky test run: https://github.com/getsentry/sentry-python/actions/runs/28110662230/job/83239750332

Summary

  • Fix flaky test_propagator_loaded_if_mentioned_in_environment_variable in the potel test suite
  • The old test used importlib.reload(propagate) with a patched env var, which was flaky because OTel's _importlib_metadata caches entry_points() with @functools.cache
  • Replace with a direct importlib.metadata.entry_points() query that verifies registration, value, and loaded class

ericapisani and others added 3 commits June 24, 2026 13:25
The old test used `importlib.reload(propagate)` with a patched
`OTEL_PROPAGATORS` env var, which was flaky because OTel's
`_importlib_metadata` module caches `entry_points()` with
`@functools.cache`. Depending on when the cache was first populated,
the "sentry" entry point might not be found during the reload.

Replace with a direct `importlib.metadata.entry_points()` query that
verifies the entry point is registered, has the correct value, and
loads to `SentryPropagator`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use importlib_metadata backport fallback for Python 3.7, and handle
the dict return type from entry_points() on older Python versions
where keyword filtering isn't supported.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Editable installs on some Python versions register the entry point
twice (via setup.py and dist-info). Assert >= 1 match instead of
exactly 1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

89837 passed | ⏭️ 6240 skipped | Total: 96077 | Pass Rate: 93.51% | Execution Time: 318m 51s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2402 uncovered lines.
✅ Project coverage is 89.89%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.89%    89.89%        —%
==========================================
  Files          192       192         —
  Lines        23763     23763         —
  Branches      8206      8206         —
==========================================
+ Hits         21360     21361        +1
- Misses        2403      2402        -1
- Partials      1343      1342        -1

Generated by Codecov Action

@ericapisani ericapisani marked this pull request as ready for review June 24, 2026 18:17
@ericapisani ericapisani requested a review from a team as a code owner June 24, 2026 18:17
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