Skip to content

Commit

Permalink
deps(metrics-example): update opentelemetry to 0.27
Browse files Browse the repository at this point in the history
this will help fix the `cargo deny` situation as `opentelemetry-otlp` `0.25` has `tokio` [locked to `~1.38.0`](https://crates.io/crates/opentelemetry-otlp/0.25.0/dependencies) 🤷‍♂️
which then impedes us tfrom updating `netlink-sys`

Pull-Request: #5735.
  • Loading branch information
jxs authored Dec 12, 2024
1 parent cda1470 commit 99544c4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
45 changes: 23 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ release = false
futures = { workspace = true }
axum = "0.7"
libp2p = { path = "../../libp2p", features = ["tokio", "metrics", "ping", "noise", "identify", "tcp", "yamux", "macros"] }
opentelemetry = { version = "0.25.0", features = ["metrics"] }
opentelemetry-otlp = { version = "0.25.0", features = ["metrics"] }
opentelemetry_sdk = { version = "0.25.0", features = ["rt-tokio", "metrics"] }
opentelemetry = { version = "0.27.0", features = ["metrics"] }
opentelemetry-otlp = { version = "0.27.0", features = ["metrics"] }
opentelemetry_sdk = { version = "0.27.0", features = ["rt-tokio", "metrics"] }
prometheus-client = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tracing = { workspace = true }
tracing-opentelemetry = "0.26.0"
tracing-opentelemetry = "0.28.0"
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[lints]
Expand Down
22 changes: 13 additions & 9 deletions examples/metrics/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ use libp2p::{
swarm::{NetworkBehaviour, SwarmEvent},
tcp, yamux,
};
use opentelemetry::{trace::TracerProvider, KeyValue};
use opentelemetry::{trace::TracerProvider as _, KeyValue};
use opentelemetry_otlp::SpanExporter;
use opentelemetry_sdk::{runtime, trace::TracerProvider};
use prometheus_client::registry::Registry;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer};

Expand Down Expand Up @@ -92,14 +94,16 @@ async fn main() -> Result<(), Box<dyn Error>> {
}

fn setup_tracing() -> Result<(), Box<dyn Error>> {
let provider = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(opentelemetry_otlp::new_exporter().tonic())
.with_trace_config(opentelemetry_sdk::trace::Config::default().with_resource(
opentelemetry_sdk::Resource::new(vec![KeyValue::new("service.name", "libp2p")]),
))
.install_batch(opentelemetry_sdk::runtime::Tokio)?;

let provider = TracerProvider::builder()
.with_batch_exporter(
SpanExporter::builder().with_tonic().build()?,
runtime::Tokio,
)
.with_resource(opentelemetry_sdk::Resource::new(vec![KeyValue::new(
"service.name",
"libp2p",
)]))
.build();
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer().with_filter(EnvFilter::from_default_env()))
.with(
Expand Down

0 comments on commit 99544c4

Please sign in to comment.