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

PreSampledTrace Failure #1340

Closed
hdost opened this issue Nov 2, 2023 · 8 comments
Closed

PreSampledTrace Failure #1340

hdost opened this issue Nov 2, 2023 · 8 comments
Assignees
Labels
A-trace Area: issues related to tracing

Comments

@hdost
Copy link
Contributor

hdost commented Nov 2, 2023

Ran into an interesting edge case when trying to put together a sample for open-telemetry/opentelemetry-rust-contrib#137
It seems like they're using OpenTelemetryOTLP exporting. However that's not the main topic here. We have a weird interaction that seems to be happening at it relates to a special trait that's being run. I'm not 100 sure it requires an API change, but it could.

opentelemetry-rust/examples/tracing-axum on  main [$!?] is 📦 v0.1.0 via 🦀 v1.73.0
at 16:25:51 ➜  cargo build
    Blocking waiting for file lock on build directory
   Compiling tracing-axum v0.1.0 (/home/h.dost/projects/github.com/hdost/opentelemetry-rust/examples/tracing-axum)
error[E0277]: the trait bound `opentelemetry_sdk::trace::Tracer: opentelemetry_api::trace::tracer::Tracer` is not satisfied
   --> examples/tracing-axum/src/main.rs:20:64
    |
20  |     let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
    |                                                    ----------- ^^^^^^ the trait `opentelemetry_api::trace::tracer::Tracer` is not implemented for `opentelemetry_sdk::trace::Tracer`
    |                                                    |
    |                                                    required by a bound introduced by this call
    |
    = help: the following other types implement trait `opentelemetry_api::trace::tracer::Tracer`:
              opentelemetry_api::global::trace::BoxedTracer
              opentelemetry_api::trace::noop::NoopTracer
              opentelemetry_sdk::trace::tracer::Tracer
note: required by a bound in `OpenTelemetryLayer::<S, T>::with_tracer`
   --> /home/h.dost/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-opentelemetry-0.21.0/src/layer.rs:469:17
    |
467 |     pub fn with_tracer<Tracer>(self, tracer: Tracer) -> OpenTelemetryLayer<S,...
    |            ----------- required by a bound in this associated function
468 |     where
469 |         Tracer: otel::Tracer + PreSampledTracer + 'static,
    |                 ^^^^^^^^^^^^ required by this bound in `OpenTelemetryLayer::<S, T>::with_tracer`

error[E0277]: the trait bound `opentelemetry_sdk::trace::Tracer: PreSampledTracer` is not satisfied
   --> examples/tracing-axum/src/main.rs:20:64
    |
20  |     let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
    |                                                    ----------- ^^^^^^ the trait `PreSampledTracer` is not implemented for `opentelemetry_sdk::trace::Tracer`
    |                                                    |
    |                                                    required by a bound introduced by this call
    |
    = help: the following other types implement trait `PreSampledTracer`:
              opentelemetry_api::trace::noop::NoopTracer
              opentelemetry_sdk::trace::tracer::Tracer
note: required by a bound in `OpenTelemetryLayer::<S, T>::with_tracer`
   --> /home/h.dost/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-opentelemetry-0.21.0/src/layer.rs:469:32
    |
467 |     pub fn with_tracer<Tracer>(self, tracer: Tracer) -> OpenTelemetryLayer<S,...
    |            ----------- required by a bound in this associated function
468 |     where
469 |         Tracer: otel::Tracer + PreSampledTracer + 'static,
    |                                ^^^^^^^^^^^^^^^^ required by this bound in `OpenTelemetryLayer::<S, T>::with_tracer`

The code is included here #1339

Not sure if there's any API changed required here, instead it might actually require filing something on the tracing-opentelemetry crate. This could however require some sort of API change.

@jtescher is this something around a generic implementation?

@hdost hdost added the A-trace Area: issues related to tracing label Nov 2, 2023
@hdost hdost added this to the Tracing API Stable milestone Nov 2, 2023
@jtescher
Copy link
Member

jtescher commented Nov 2, 2023

Are you using the latest version of the sdk?

@TommyCpp
Copy link
Contributor

TommyCpp commented Nov 2, 2023

Could be version mismatch. You should use 0.20 of opentelemetry.

Note that since tracing-opentelemetry is not in this repo. It usually depends on last release version instead of the current main version.

@hdost
Copy link
Contributor Author

hdost commented Nov 2, 2023

So as mentioned I have a PR with an example. The #1339 does work, but I had to use versioned_tracer() which mean s that people aren't allowed to use tracer() due to the current type constraints.

@jtescher
Copy link
Member

jtescher commented Nov 7, 2023

@hdost which constraints? they should both be referencing the same type https://docs.rs/opentelemetry/0.21.0/opentelemetry/trace/trait.TracerProvider.html

@hdost
Copy link
Contributor Author

hdost commented Nov 10, 2023

The tooling requires the PreSampledTracer trait to be implemented, but the implementation is only done for NoopTracer and for the SdkTracer (which with our recent rename will also fail). I believe we may need to have tracing-opentelemetry implementation be a blanket for any Tracer and that should work.

@hdost
Copy link
Contributor Author

hdost commented Nov 29, 2023

Could be version mismatch. You should use 0.20 of opentelemetry.

Sorry I missed this comment.

@hdost hdost self-assigned this Nov 29, 2023
@undecidedapollo
Copy link

@hdost What ended up being the solution for this? I'm encountering the same issue.

@hdost
Copy link
Contributor Author

hdost commented Mar 18, 2024

@hdost What ended up being the solution for this? I'm encountering the same issue.

I had mismatched versions.

#1340 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trace Area: issues related to tracing
Projects
None yet
Development

No branches or pull requests

5 participants