Repository navigation
[Exporter.Prometheus] Fix concurrency issue - #7571
Conversation
Fix concurrency issue introduced by the fix in open-telemetry#7524.
Pull request dashboard statusMerged · refreshed 2026-08-04 12:10 UTC Status above doesn't look right?
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7571 +/- ##
==========================================
+ Coverage 90.44% 90.67% +0.22%
==========================================
Files 290 290
Lines 15989 16434 +445
==========================================
+ Hits 14462 14901 +439
- Misses 1527 1533 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
The previous fix introduced a deadlock - instead, remove the retries and return an error instead.
There was a problem hiding this comment.
Pull request overview
This pull request updates the Prometheus exporter scrape/collection coordination to avoid pathological retry behavior under contention. It changes the PrometheusCollectionManager so that scrapes which shared a collection that ultimately failed will also fail (rather than retrying and potentially stalling), and updates the associated unit test and package changelogs.
Changes:
- Change
PrometheusCollectionManagerto return a failedCollectionResponsewhen a scrape joined a collection that produced no response for its protocol, instead of retrying. - Update the concurrency unit test to assert that all scrapes sharing a failed collection report failure (and that the collection is not re-run on their behalf).
- Add CHANGELOG entries for both Prometheus exporter packages.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs | Updates concurrency test to validate “fail-fast” behavior for scrapes sharing a failed collection. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/Internal/Shared/PrometheusCollectionManager.cs | Adjusts retry/failure logic in WaitForCollectionResponseAsync to avoid retrying after a shared failed collection. |
| src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md | Adds an Unreleased entry describing the behavior change. |
| src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md | Adds an Unreleased entry describing the behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove spinning to avoid additional contention issues. - Fix flaky test by ensuring there are enough free threads.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusCollectionManagerTests.cs:304
- This new deadlock-regression test can hang indefinitely if
EnterCollectregresses to synchronously blocking while waiting for active readers (the call toEnterCollectAsyncis made on the same thread that is holding a reader slot). Add an explicit xUnit timeout so the suite fails fast instead of stalling CI when the regression reproduces.
[Fact]
Refactor test to avoid hang in CI if there is a regression.
2ae52ae
Changes
Fix concurrency issue introduced by the fix in #7524. Now, instead of retrying under failed scrapes under contention, instead return an error.
A first attempt at fixing the issue made things work by introducing a deadlock, and the original fix that created this secondary issue was for a stack overflow, so at this point it's probably safer to fail faster if under high contention (which realistically shouldn't happen to a scrape endpoint?) and let the client itself retry.
Detected by test flakiness in #6899. This job took 6 attempts to pass - for some reason the bug is more apparent only when running under .NET 11.
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)