Skip to content

Commit

Permalink
fix: update opentelemetry-tracing example
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliboy50 committed Jun 28, 2024
1 parent 0bd48b1 commit 2842e60
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions examples/opentelemetry-tracing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

0 comments on commit 2842e60

Please sign in to comment.