Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenTelemetryLayer to lambda_runtime layers #866

Closed
ollis opened this issue May 2, 2024 · 3 comments · Fixed by #898
Closed

Add OpenTelemetryLayer to lambda_runtime layers #866

ollis opened this issue May 2, 2024 · 3 comments · Fixed by #898

Comments

@ollis
Copy link

ollis commented May 2, 2024

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

@calavera
Copy link
Contributor

calavera commented May 3, 2024

Providing that layer can be a good idea since multiple people seem to use it.

OpenTelemetry and Tracing are two completely separated tracing systems. Adding both layers is not going to do what you expect. You need to use the Tracing / Open Telemetry integration for that: https://docs.rs/tracing-opentelemetry/latest/tracing_opentelemetry/

@ollis
Copy link
Author

ollis commented May 4, 2024

Both TracingLayer and OpenTelemetryLayer uses tracing::info_span! from the tracing crate. So if I created MyCustomLayer and added some tracing::info_span! statements I would expect them to be nested within spans from an outer layer? (I used TracingLayer in the example just for simplicity) I have already set up tracing_opentelemetry in order to emit the events to Jaeger where the attached image is taken.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants