frigus02 / opentelemetry-application-insights

OpenTelemetry exporter for Azure Application Insights
MIT License
22 stars 12 forks source link

method cannot be called on `PipelineBuilder<Client>` due to unsatisfied trait bounds #85

Closed preedep closed 2 months ago

preedep commented 3 months ago

when I build , I've got error "method cannot be called on PipelineBuilder<Client> due to unsatisfied trait bounds" at install_batch

 let _tracer = opentelemetry_application_insights::new_pipeline_from_env()
        .expect("environment variable not found")
        .with_client(reqwest::Client::new())
        .with_live_metrics(true)
        .with_service_name("my-service")
        .install_batch( opentelemetry_sdk::runtime::Tokio);

my dependencies

opentelemetry = { version = "0.23" , features = ["logs_level_enabled","metrics","trace"] }
opentelemetry_sdk = {version = "0.23", features = ["logs_level_enabled","metrics","trace","rt-tokio","opentelemetry-http"]}
opentelemetry-application-insights = {version = "0.33", features = ["metrics", "live-metrics", "reqwest-client-rustls"]}
reqwest = { version = "0.12", default-features = false,features = ["charset","http2","rustls-tls", "json"] }
frigus02 commented 3 months ago

Hi. It looks like the issue is the reqwest version. When I try to build with the depenencies you listed and I look into my Cargo.lock file, I see reqwest is included in both a 0.11 and a 0.12 version and opentelemetry-http (which implements the required trait) depends on the 0.11 version.

When you switch to reqwest 0.11 in your Cargo.toml (and remove the charset and http2 features, which are new in 0.12) the code starts to compile.

I'm not sure why this happens, yet. I assume either opentelemetry-application-insights or opentelemetry-http (or both) declare the reqwest dependency incorrectly. My intention was to have 0.11 as the minium version but allow any higher version, too. I guess that's not what this does?

https://github.com/frigus02/opentelemetry-application-insights/blob/02d8ac430d579fb707840c36b48dbba7af0641ef/Cargo.toml#L47

https://github.com/open-telemetry/opentelemetry-rust/blob/0303a38758dd5822a7fbc809f6623ab69caf02c1/Cargo.toml#L37

frigus02 commented 3 months ago

Okay. The default version requirement is the caret requirement: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements

I suppose what we really need here a https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#comparison-requirements, sth like: >=0.11