[Sampler.AWS] Fix flaky tests#4297
Conversation
- Fix flaky tests by refactoring the handling of the background timer. - Avoid allocations when creating a client ID. - Remove some code duplication in the tests. - Avoid private reflection. - Increase `SpinWait` timeout.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4297 +/- ##
==========================================
- Coverage 75.28% 75.12% -0.17%
==========================================
Files 467 467
Lines 18449 18493 +44
==========================================
+ Hits 13889 13892 +3
- Misses 4560 4601 +41 Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce flakiness in the AWS X-Ray remote sampler tests by refactoring the sampler’s background polling/timer handling, along with a few test-stability improvements across the test suite.
Changes:
- Refactors
AWSXRayRemoteSamplerpolling callbacks and disposal behavior (timer handling, cancellation, locking) and reduces allocations for client-id generation. - Updates AWS sampler tests to reduce duplication and avoid reflective invocation of private methods.
- Improves test robustness by broadening tolerated
HttpListenerExceptioncases and increasing aSpinWaittimeout in ASP.NET Core tests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Shared/TestHttpServer.cs | Treats an additional HttpListenerException error code as a benign shutdown/disconnect case. |
| test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRayRemoteSampler.cs | Refactors tests to use a helper and calls the new internal async target-update method. |
| test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs | Increases export wait timeout to reduce flakiness under parallel load. |
| src/OpenTelemetry.Sampler.AWS/AWSXRayRemoteSampler.cs | Refactors polling execution/disposal and updates client-id generation to reduce allocations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Avoid potential deadlock.
Changes
SpinWaittimeout to avoid a different flaky test.The parts around removing
async voidwere suggested by Copilot when I asked it to investigate the issue.Merge requirement checklist
AppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)