Skip to content

Commit 2842e60

Browse files
committed
fix: update opentelemetry-tracing example
1 parent 0bd48b1 commit 2842e60

File tree

1 file changed

+9
-4
lines changed
  • examples/opentelemetry-tracing/src

1 file changed

+9
-4
lines changed

examples/opentelemetry-tracing/src/main.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ async fn main() -> Result<(), BoxError> {
2424
.init();
2525

2626
// Initialize the Lambda runtime and add OpenTelemetry tracing
27-
let runtime = Runtime::new(service_fn(echo)).layer(OtelLayer::new(|| {
28-
// Make sure that the trace is exported before the Lambda runtime is frozen
29-
tracer_provider.force_flush();
30-
}));
27+
let runtime = Runtime::new(service_fn(echo)).layer(
28+
// Create a tracing span for each Lambda invocation
29+
OtelLayer::new(|| {
30+
// Make sure that the trace is exported before the Lambda runtime is frozen
31+
tracer_provider.force_flush();
32+
})
33+
// Set the "faas.trigger" attribute of the span (defaults to "http" otherwise)
34+
.with_trigger("datasource"),
35+
);
3136
runtime.run().await?;
3237
Ok(())
3338
}

0 commit comments

Comments
 (0)