Skip to content

Commit

Permalink
Now we wait on axum-tracing-opentelemetry to update
Browse files Browse the repository at this point in the history
  • Loading branch information
xd009642 committed Dec 12, 2024
1 parent 955e1f3 commit 1eec2b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
7 changes: 5 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ init-tracing-opentelemetry = { version = "0.19.0", features =["tracing_subscribe
measured = "0.0.22"
metrics = "0.24.0"
metrics-exporter-prometheus = "0.16.0"
opentelemetry = "0.23.0" # otel versions are tied to `init-tracing-opentelemetry` and `axum-tracing-opentelemetry` for trait compat
opentelemetry = "0.27.0" # otel versions are tied to `init-tracing-opentelemetry` and `axum-tracing-opentelemetry` for trait compat
opentelemetry-otlp = "0.27.0"
opentelemetry-semantic-conventions = "0.15.0"
opentelemetry_sdk = { version = "0.23.0", features = ["rt-tokio", "trace"] }
opentelemetry_sdk = { version = "0.27.0", features = ["rt-tokio", "trace"] }
quanta = "0.12.3"
rubato = { version = "0.15.0", default-features = false }
serde = { version = "1.0.200", features = ["derive"] }
Expand Down
29 changes: 14 additions & 15 deletions src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,33 +179,32 @@ pub fn setup_logging() -> anyhow::Result<Tracer> {
Ok(_) => EnvFilter::from_env("RUST_LOG"),
_ => EnvFilter::new("client=info,streamer_template=info"),
};

let service_name = "streaming-client";
let builder = opentelemetry_otlp::new_exporter().tonic();
let builder = match env::var("TRACER_ENDPOINT") {

let otlp_exporter = opentelemetry_otlp::SpanExporter::builder().with_tonic();
let otlp_exporter = match env::var("TRACER_ENDPOINT") {
Ok(s) => {
info!("Setting otel endpoint to {}", s);
builder.with_endpoint(s)
otlp_exporter.with_endpoint(s)
}
_ => builder,
_ => otlp_exporter,
};
println!("Builder: {:?}", builder);
let otlp_exporter = otlp_exporter.build()?;

let trace_provider = opentelemetry_otlp::new_pipeline()
.tracing()
.with_exporter(builder)
.with_trace_config(
let service_name = "streaming-client";
let trace_provider = opentelemetry_sdk::trace::TracerProvider::builder()
.with_simple_exporter(otlp_exporter)
.with_config(
sdktrace::Config::default().with_resource(Resource::new(vec![KeyValue::new(
SERVICE_NAME,
service_name,
)])),
)
.install_batch(opentelemetry_sdk::runtime::Tokio)?;
.build();


global::set_text_map_propagator(TraceContextPropagator::new());

let provider = trace_provider.provider().context("No trace provider")?;
let tracer = provider.tracer(service_name.to_string());
let tracer = trace_provider.tracer(service_name.to_string());

let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer.clone());
let fmt = tracing_subscriber::fmt::Layer::default();
Expand All @@ -215,6 +214,6 @@ pub fn setup_logging() -> anyhow::Result<Tracer> {
.with_subscriber(Registry::default());

tracing::subscriber::set_global_default(subscriber)?;
global::set_tracer_provider(provider);
global::set_tracer_provider(trace_provider);
Ok(tracer)
}

0 comments on commit 1eec2b2

Please sign in to comment.