Skip to content

Add OpenTelemetryLayer to lambda_runtime layers #866

Closed
@ollis

Description

@ollis

Hi, I have started testing OpenTelemetry integration and I found the example given here really useful: https://github.com/awslabs/aws-lambda-rust-runtime/blob/main/examples/opentelemetry-tracing/src/lib.rs

I have copied the code into my project but I am wondering if it could be packaged into the distributed crate, maybe behind an opentelemetry feature flag?

I have also tried using nested layers and I would expect this to create child spans but this is not what I am observing. Is this a feature or a bug?

Given this setup I would expect the span of Tracing-layer to be a child of the OpenTelemetry-layer span:

 let runtime = Runtime::new(handler)
            .layer(layers::TracingLayer::new())
            .layer(OpenTelemetryLayer::new(|| {
                tracer
                    .provider()
                    .expect("Unable to get tracer provider!")
                    .force_flush();
            }));

But this is the result (function_name is customer-lookup):
Screenshot 2024-05-02 at 08 11 20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions