Skip to content

Conversation

@Kile-Asmussen
Copy link

Fixes #3291

Changes

Deprecate the FutureExt trait and introduce three separate extension traits handling futures, streams, and sinks spearately: FutureContextExt, StreamContextExt and SinkContextExt which 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:

  • Moved opentelemetry/src/context.rs to opentelemetry/src/context/mod.rs in accordance with the code organization style of the rest of the project.
  • Removed re-export of FutureExt and WithContext through opentelemetry::trace::context which was marked as "Re-exported for compatibility" since clippy marked it as unreachable once cleaned up the exports in other modules.
  • Moved 0.5KLOC tests from opentelemetry/src/context/mod.rs to opentelemetry/src/context/test.rs to reduce clutter.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@Kile-Asmussen Kile-Asmussen requested a review from a team as a code owner December 27, 2025 21:36
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 27, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Dec 27, 2025

Codecov Report

❌ Patch coverage is 89.13738% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.4%. Comparing base (2b63b75) to head (390a19e).

Files with missing lines Patch % Lines
opentelemetry/src/context/future_ext.rs 20.0% 24 Missing ⚠️
opentelemetry/src/context/tests.rs 96.4% 10 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a 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 FutureExt and introduce FutureContextExt, StreamContextExt, and SinkContextExt with 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.

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.

[Feature]: Deprecate FutureExt trait for having a far too general blanket implementation

1 participant