From 2842e60be3d7397057eb03747487b4e5ac1b43d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Th=C3=A9bault?= Date: Fri, 28 Jun 2024 15:38:25 +0200 Subject: [PATCH] fix: update opentelemetry-tracing example --- examples/opentelemetry-tracing/src/main.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/opentelemetry-tracing/src/main.rs b/examples/opentelemetry-tracing/src/main.rs index 4020d87c..b9756755 100644 --- a/examples/opentelemetry-tracing/src/main.rs +++ b/examples/opentelemetry-tracing/src/main.rs @@ -24,10 +24,15 @@ async fn main() -> Result<(), BoxError> { .init(); // Initialize the Lambda runtime and add OpenTelemetry tracing - let runtime = Runtime::new(service_fn(echo)).layer(OtelLayer::new(|| { - // Make sure that the trace is exported before the Lambda runtime is frozen - tracer_provider.force_flush(); - })); + let runtime = Runtime::new(service_fn(echo)).layer( + // Create a tracing span for each Lambda invocation + OtelLayer::new(|| { + // Make sure that the trace is exported before the Lambda runtime is frozen + tracer_provider.force_flush(); + }) + // Set the "faas.trigger" attribute of the span (defaults to "http" otherwise) + .with_trigger("datasource"), + ); runtime.run().await?; Ok(()) }