-
Notifications
You must be signed in to change notification settings - Fork 616
Replace FutureExt trait with better extension traits #3292
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
base: main
Are you sure you want to change the base?
Conversation
… precise blanket impls
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3292 +/- ##
=======================================
- Coverage 80.5% 80.4% -0.2%
=======================================
Files 129 130 +1
Lines 23294 23325 +31
=======================================
+ Hits 18756 18757 +1
- Misses 4538 4568 +30 ☔ View full report in Codecov by Sentry. 🚀 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 addresses issue #3291 by deprecating the overly general FutureExt trait and replacing it with three specialized extension traits that have precise blanket implementations. The changes ensure better type safety and prevent the trait from appearing in autocomplete for unrelated types.
Key Changes:
- Deprecate
FutureExtand introduceFutureContextExt,StreamContextExt, andSinkContextExtwith identical functionality but precise implementations - Reorganize code structure by moving tests to a separate file and refactoring module organization
- Update all documentation and examples to use the new trait names
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| opentelemetry/src/trace/tracer.rs | Updated documentation to reference FutureContextExt instead of deprecated FutureExt |
| opentelemetry/src/trace/mod.rs | Updated module exports to include new traits and maintain backward compatibility with deprecated FutureExt |
| opentelemetry/src/trace/context.rs | Removed re-export of FutureExt and WithContext that was marked for compatibility |
| opentelemetry/src/context/tests.rs | New test file containing all context-related tests moved from mod.rs (536 lines) |
| opentelemetry/src/context/mod.rs | Restructured module to separate tests and updated exports for new traits |
| opentelemetry/src/context/future_ext.rs | Added three new extension traits with deprecation notices on the old trait, includes incomplete comment that needs fixing |
| opentelemetry/CHANGELOG.md | Documented breaking change and new traits with minor grammar issue |
| examples/tracing-http-propagator/src/server.rs | Updated example code to use FutureContextExt |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #3291
Changes
Deprecate the
FutureExttrait and introduce three separate extension traits handling futures, streams, and sinks spearately:FutureContextExt,StreamContextExtandSinkContextExtwhich have precise blanket implementations.Usage of these three new traits is completely identical to the deprecated one. The trait functions have the same names, and signatures. (They just don't show up in the rust-analyzer autocomplete of
Option<String>.)Some additional cleanup:
opentelemetry/src/context.rstoopentelemetry/src/context/mod.rsin accordance with the code organization style of the rest of the project.FutureExtandWithContextthroughopentelemetry::trace::contextwhich was marked as "Re-exported for compatibility" since clippy marked it as unreachable once cleaned up the exports in other modules.opentelemetry/src/context/mod.rstoopentelemetry/src/context/test.rsto reduce clutter.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes