From b931dac9f51699443a18ea146d2ff1d9c837d661 Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Fri, 29 Nov 2024 22:21:22 +0100 Subject: [PATCH] chore: cleanup --- controller/src/bin/patagia-controller.rs | 11 ++++++++++- controller/src/instrumentation.rs | 13 +++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/controller/src/bin/patagia-controller.rs b/controller/src/bin/patagia-controller.rs index 0c4719b..cf268ad 100644 --- a/controller/src/bin/patagia-controller.rs +++ b/controller/src/bin/patagia-controller.rs @@ -7,6 +7,7 @@ use dropshot::{ use schemars::JsonSchema; use serde::Serialize; use slog::Drain; +use tracing::Instrument; use tracing_slog::TracingSlogDrain; use std::net::SocketAddr; @@ -49,7 +50,15 @@ async fn api_version( version: env!("CARGO_PKG_VERSION").to_string(), }; - tracing::info!("Someone made a request to /version"); + tracing::info_span!("Hello, span!"); + + async move { + tracing::info!("Someone made a request to /version"); + + tokio::time::sleep(std::time::Duration::from_millis(200)).await; + } + .instrument(tracing::info_span!("Let's do the thing....")) + .await; Ok(HttpResponseOk(ver)) } diff --git a/controller/src/instrumentation.rs b/controller/src/instrumentation.rs index eadba53..44f3807 100644 --- a/controller/src/instrumentation.rs +++ b/controller/src/instrumentation.rs @@ -68,14 +68,11 @@ fn init_tracer_provider() -> Result { .map_err(|e| anyhow!("Error creating OTLP span exporter: {:?}", e))?; let tracer_provider = opentelemetry_sdk::trace::TracerProvider::builder() - .with_config( - opentelemetry_sdk::trace::Config::default() - .with_sampler(Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased( - 1.0, - )))) - .with_id_generator(RandomIdGenerator::default()) - .with_resource(RESOURCE.clone()), - ) + .with_sampler(Sampler::ParentBased(Box::new(Sampler::TraceIdRatioBased( + 1.0, + )))) + .with_resource(RESOURCE.clone()) + .with_id_generator(RandomIdGenerator::default()) .with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio) .build();