diff --git a/examples/bank-accounting/Cargo.toml b/examples/bank-accounting/Cargo.toml index d4c85ae5..e1fd53e0 100644 --- a/examples/bank-accounting/Cargo.toml +++ b/examples/bank-accounting/Cargo.toml @@ -15,7 +15,8 @@ eventually = { path = "../../eventually", features = [ eventually-macros = { path = "../../eventually-macros" } eventually-postgres = { path = "../../eventually-postgres" } opentelemetry = "0.21.0" -opentelemetry-jaeger = "0.20.0" +opentelemetry-otlp = "0.14.0" +opentelemetry_sdk = { version = "0.21.2", features = ["rt-tokio"] } prost = "0.12.3" rust_decimal = "1.34.3" sqlx = { version = "0.7.3", features = ["runtime-tokio-rustls", "postgres"] } diff --git a/examples/bank-accounting/src/tracing.rs b/examples/bank-accounting/src/tracing.rs index 987148f8..681e5313 100644 --- a/examples/bank-accounting/src/tracing.rs +++ b/examples/bank-accounting/src/tracing.rs @@ -1,12 +1,21 @@ use anyhow::anyhow; +use opentelemetry::KeyValue; +use opentelemetry_sdk::{trace, Resource}; use tracing_subscriber::prelude::*; use tracing_subscriber::EnvFilter; -pub fn initialize(service_name: &str) -> anyhow::Result<()> { - let tracer = opentelemetry_jaeger::new_agent_pipeline() - .with_service_name(service_name) - .install_simple() - .map_err(|e| anyhow!("failed to initialize jaeger tracer: {}", e))?; +pub fn initialize(service_name: &'static str) -> anyhow::Result<()> { + let tracer = opentelemetry_otlp::new_pipeline() + .tracing() + .with_exporter(opentelemetry_otlp::new_exporter().tonic()) + .with_trace_config( + opentelemetry_sdk::trace::config() + .with_sampler(trace::Sampler::AlwaysOn) + .with_id_generator(trace::RandomIdGenerator::default()) + .with_resource(Resource::new([KeyValue::new("service.name", service_name)])), + ) + .install_batch(opentelemetry_sdk::runtime::Tokio) + .map_err(|e| anyhow!("failed to initialize OTLP tracer: {}", e))?; let filter_layer = EnvFilter::try_from_default_env() .or_else(|_| EnvFilter::try_new("info"))