-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Check context prior to delaying retry in OTLP exporters #7678
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
Conversation
Fix open-telemetry#7673 Do not rely on non-deterministic `select` statement to catch ended context prior to waiting for a retry delay. Explicitly check the context prior to entering the wait.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7678 +/- ##
=======================================
- Coverage 86.1% 86.0% -0.2%
=======================================
Files 298 298
Lines 21709 21727 +18
=======================================
- Hits 18707 18696 -11
- Misses 2625 2630 +5
- Partials 377 401 +24
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds explicit context cancellation checks to OTLP exporters' retry logic to eliminate reliance on non-deterministic select statement behavior. The change ensures requests with canceled contexts fail immediately without waiting for retry delays, fixing a flaky test issue.
- Adds
ctx.Err()check immediately after determining an error is retryable but before attempting any retry delay - Uses consistent error wrapping pattern
fmt.Errorf("%w: %w", ctx.Err(), err)to preserve both the context error and original error - Applied uniformly across all OTLP exporter variants (trace/metric/log over HTTP/gRPC)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/shared/otlp/retry/retry.go.tmpl | Template source adding context check before retry wait logic |
| exporters/otlp/otlptrace/otlptracehttp/internal/retry/retry.go | Generated file for HTTP trace exporter with context check |
| exporters/otlp/otlptrace/otlptracegrpc/internal/retry/retry.go | Generated file for gRPC trace exporter with context check |
| exporters/otlp/otlpmetric/otlpmetrichttp/internal/retry/retry.go | Generated file for HTTP metric exporter with context check |
| exporters/otlp/otlpmetric/otlpmetricgrpc/internal/retry/retry.go | Generated file for gRPC metric exporter with context check |
| exporters/otlp/otlplog/otlploghttp/internal/retry/retry.go | Generated file for HTTP log exporter with context check |
| exporters/otlp/otlplog/otlploggrpc/internal/retry/retry.go | Generated file for gRPC log exporter with context check |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix #7673
Issue being addressed:
Do not rely on non-deterministic
selectstatement to catch ended context prior to waiting for a retry delay. Explicitly check the context prior to entering the wait.This resolves the flaky test and ensure in normal operation that requests with canceled context are ended without having to wait for any additional delays.