Skip to content
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

pub use opentelemetry_api::trace::WithContext #893

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

mkatychev
Copy link
Contributor

@mkatychev mkatychev commented Oct 11, 2022

Resolves #823

This scenario is specifically meant to make instrumenting async functions with contexts:

pub trait InstrumentWithContext: Instrument {
    fn instrument_cx(self, span: tracing::Span) -> Instrumented<WithContext<Self>>;
}

impl<T> InstrumentWithContext for T
where
    T: Instrument,
{
    fn instrument_cx(self, span: tracing::Span) -> Instrumented<WithContext<T>> {
        self.with_context(span.context()).instrument(span)
    }
}

Right now, calling some_async_fn().instrument(tracing_span) does not set the span's context as the some_async_fn's current Context.

Instead, the current flow is to chain both methods: some_async_fn().with_context(span.context()).instrument(span).await

This is a first step to bundling ot Contexts more consistently.

Traits involved:

@mkatychev mkatychev requested a review from a team as a code owner October 11, 2022 19:12
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 11, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: mkatychev / name: Mikhail Katychev (baa4ca8)

Copy link
Member

@jtescher jtescher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good thanks @mkatychev

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Base: 67.0% // Head: 67.0% // No change to project coverage 👍

Coverage data is based on head (baa4ca8) compared to base (1faeabc).
Patch has no changes to coverable lines.

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #893   +/-   ##
=====================================
  Coverage   67.0%   67.0%           
=====================================
  Files        114     114           
  Lines       8914    8914           
=====================================
  Hits        5975    5975           
  Misses      2939    2939           
Impacted Files Coverage Δ
opentelemetry-api/src/trace/mod.rs 76.5% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

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.

WithContext is not exposed through exports
2 participants