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

can't crate layer after upgrading opentelemetry to 0.27 #185

Closed
nbari opened this issue Nov 13, 2024 · 2 comments
Closed

can't crate layer after upgrading opentelemetry to 0.27 #185

nbari opened this issue Nov 13, 2024 · 2 comments

Comments

@nbari
Copy link

nbari commented Nov 13, 2024

Version

cargo tree | grep tracing
│   │   └── tracing v0.1.40
│   │       ├── tracing-attributes v0.1.27 (proc-macro)
│   │       └── tracing-core v0.1.32
│   │   │   └── tracing v0.1.40 (*)
│   │   └── tracing v0.1.40 (*)
│   │   └── tracing v0.1.40 (*)
│   └── tracing v0.1.40 (*)
│   │   │   └── tracing v0.1.40 (*)
│   │       │   └── tracing v0.1.40 (*)
│   │       └── tracing v0.1.40 (*)
│   └── tracing v0.1.40 (*)
│   │   ├── tracing v0.1.40 (*)
│   │   │   │   ├── tracing v0.1.40 (*)
│       ├── tracing v0.1.40 (*)
│   ├── tracing v0.1.40 (*)
├── tracing v0.1.40 (*)
├── tracing-opentelemetry v0.27.0
│   ├── tracing v0.1.40 (*)
│   ├── tracing-core v0.1.32 (*)
│   ├── tracing-log v0.2.0
│   │   └── tracing-core v0.1.32 (*)
│   └── tracing-subscriber v0.3.18
│       ├── tracing v0.1.40 (*)
│       ├── tracing-core v0.1.32 (*)
│       ├── tracing-log v0.2.0 (*)
│       └── tracing-serde v0.1.3
│           └── tracing-core v0.1.32 (*)
├── tracing-subscriber v0.3.18 (*)

Platform

Linux test 6.11.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 01 Nov 2024 03:30:41 +0000 x86_64 GNU/Linux

Description

I upgraded to opentelemetry 0.27 but can't make a tracer layer, output of cargo tree | grep opentelemetry:

├── opentelemetry v0.27.0
├── opentelemetry-otlp v0.27.0
│   ├── opentelemetry v0.27.0 (*)
│   ├── opentelemetry-proto v0.27.0
│   │   ├── opentelemetry v0.27.0 (*)
│   │   ├── opentelemetry_sdk v0.27.0
│   │   │   ├── opentelemetry v0.27.0 (*)
│   ├── opentelemetry_sdk v0.27.0 (*)
├── opentelemetry_sdk v0.27.0 (*)
├── tracing-opentelemetry v0.27.0
│   ├── opentelemetry v0.26.0
│   ├── opentelemetry_sdk v0.26.0
│   │   ├── opentelemetry v0.26.0 (*)

I tried this code:

use anyhow::Result;
use opentelemetry::{global, KeyValue};
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_sdk::{
    trace::{Config, TracerProvider},
    Resource,
};
use std::time::Duration;
use tracing_subscriber::{fmt, layer::SubscriberExt, EnvFilter, Registry};

/// Start the telemetry layer
/// # Errors
/// Will return an error if the telemetry layer fails to start
pub fn init(verbosity_level: tracing::Level) -> Result<()> {
    let exporter = opentelemetry_otlp::SpanExporter::builder()
        .with_tonic()
        .with_timeout(Duration::from_secs(3))
        .build()?;

    let tracer_provider = TracerProvider::builder()
        .with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio)
        .with_config(Config::default().with_resource(Resource::new(vec![
            KeyValue::new("service.name", env!("CARGO_PKG_NAME")),
            KeyValue::new("service.version", env!("CARGO_PKG_VERSION")),
        ])))
        .build();

    global::set_tracer_provider(tracer_provider);

    let tracer = global::tracer(env!("CARGO_PKG_NAME"));

    let otel_tracer_layer = tracing_opentelemetry::layer().with_tracer(tracer);

    let fmt_layer = fmt::layer()
        .with_file(true)
        .with_line_number(true)
        .with_thread_ids(false)
        .with_thread_names(false)
        .with_target(false)
        .json();

    // RUST_LOG=
    let filter = EnvFilter::builder()
        .with_default_directive(verbosity_level.into())
        .from_env_lossy()
        .add_directive("hyper=error".parse()?)
        .add_directive("tokio=error".parse()?)
        .add_directive("reqwest=error".parse()?);

    let subscriber = Registry::default()
        .with(fmt_layer)
        .with(otel_tracer_layer)
        .with(filter);

    Ok(tracing::subscriber::set_global_default(subscriber)?)
}

I expected to see this happen: "compile"

Instead, this happened:


32  |     let otel_tracer_layer = tracing_opentelemetry::layer().with_tracer(tracer);
    |                                                            ----------- ^^^^^^ the trait `opentelemetry::trace::tracer::Tracer` is not implemented for `BoxedTracer`
    |                                                            |
    |                                                            required by a bound introduced by this call
@mladedav
Copy link
Contributor

You can see in the second cargo tree you have posted you have different version of opentelemetry from what tracing-opentelemetry uses.

You need to wait for tracing-opentelemetry to update its dependency and then you need to upgrade both. Until then you cannot upgrade just opentelemetry.

@djc
Copy link
Collaborator

djc commented Nov 13, 2024

See #184.

nbari added a commit to permesi/genesis that referenced this issue Nov 24, 2024

Verified

This commit was signed with the committer’s verified signature.
@nbari nbari closed this as completed Nov 24, 2024
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

3 participants