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

tracing-opentelemetry doesn't work with latest opentelemetry crate #2306

Closed
RafalGoslawski opened this issue Sep 15, 2022 · 1 comment
Closed

Comments

@RafalGoslawski
Copy link

Bug Report

Version

$ cargo tree | grep -E 'tracing|opentelemetry'
│   │   │   └── tracing v0.1.36
│   │   │       ├── tracing-attributes v0.1.22 (proc-macro)
│   │   │       └── tracing-core v0.1.29
│   │   └── tracing v0.1.36 (*)
│   ├── tracing v0.1.36 (*)
│   │   ├── opentelemetry v0.18.0
│   │   │   ├── opentelemetry_api v0.18.0
│   │   │   └── opentelemetry_sdk v0.18.0
│   │   │       ├── opentelemetry_api v0.18.0 (*)
│   ├── opentelemetry v0.18.0 (*)
├── opentelemetry v0.18.0 (*)
├── tracing v0.1.36 (*)
├── tracing-opentelemetry v0.17.4
│   ├── opentelemetry v0.17.0
│   ├── tracing v0.1.36 (*)
│   ├── tracing-core v0.1.29 (*)
│   ├── tracing-log v0.1.3
│   │   └── tracing-core v0.1.29 (*)
│   └── tracing-subscriber v0.3.15
│       ├── tracing v0.1.36 (*)
│       ├── tracing-core v0.1.29 (*)
│       └── tracing-log v0.1.3 (*)
├── tracing-subscriber v0.3.15 (*)

Platform

Linux rafal-home 5.15.0-1017-aws #21~20.04.1-Ubuntu SMP Fri Aug 5 11:49:39 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Crates

tracing-opentelemetry v0.17.4

Description

tracing-opentelemetry v0.17.4 doesn't work with latest opentelemetry v0.18.0

I tried this example code:

use opentelemetry::exporter::trace::stdout;
use tracing::{error, span};
use tracing_subscriber::subscriber::SubscriberExt;
use tracing_subscriber::Registry;

fn main() {
    // Install a new OpenTelemetry trace pipeline
    let (tracer, _uninstall) = stdout::new_pipeline().install();

    // Create a tracing subscriber with the configured tracer
    let telemetry = tracing_opentelemetry::subscriber().with_tracer(tracer);

    // Use the tracing subscriber `Registry`, or any other subscriber
    // that impls `LookupSpan`
    let collector = Registry::default().with(telemetry);

    // Trace executed code
    tracing::collect::with_default(collector, || {
        // Spans will be sent to the configured OpenTelemetry exporter
        let root = span!(tracing::Level::TRACE, "app_start", work_units = 2);
        let _enter = root.enter();

        error!("This event will be logged in the root span.");
    });
}

I expected to see this happen: the code should compile

Instead, this happened:

error[E0277]: the trait bound `opentelemetry::sdk::trace::Tracer: opentelemetry::trace::tracer::Tracer` is not satisfied
   --> src/main.rs:11:64
    |
11  |     let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
    |                                                    ----------- ^^^^^^ the trait `opentelemetry::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::trace::tracer::Tracer`:
              opentelemetry::global::trace::BoxedTracer
              opentelemetry::sdk::trace::tracer::Tracer
              opentelemetry::trace::noop::NoopTracer
note: required by a bound in `OpenTelemetryLayer::<S, T>::with_tracer`
   --> /home/eng/.cargo/registry/src/github.com-1ecc6299db9ec823/tracing-opentelemetry-0.17.4/src/layer.rs:464:17
    |
464 |         Tracer: otel::Tracer + PreSampledTracer + 'static,
    |                 ^^^^^^^^^^^^ required by this bound in `OpenTelemetryLayer::<S, T>::with_tracer`

@hawkw
Copy link
Member

hawkw commented Sep 19, 2022

Closed by #2312 — we just published v0.18.0 of tracing-opentelemetry with support for the latest version of the opentelemetry crate.

@hawkw hawkw closed this as completed Sep 19, 2022
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

No branches or pull requests

2 participants