Closed hkford closed 5 months ago
It's explained here: https://docs.rs/lambda_runtime/latest/lambda_runtime/struct.Runtime.html#method.new
Note that manually creating a Runtime does not add tracing to the executed handler as is done by super::run. If you want to add the default tracing functionality, call Runtime::layer with a super::layers::TracingLayer.
Maybe we need to move that variable somewhere else that doesn't depend in the Tracing layer.
You can also take the information from the information context in your own layer. See how that's extracted in these two lines of code:
https://github.com/awslabs/aws-lambda-rust-runtime/blob/lambda-runtime-0.11.0/lambda-runtime/src/layers/trace.rs#L46 https://github.com/awslabs/aws-lambda-rust-runtime/blob/lambda-runtime-0.11.0/lambda-runtime/src/layers/trace.rs#L54
If you want to get the trace id in your handler, you can use event.context.xray_trace_id
: https://docs.rs/lambda_runtime/latest/lambda_runtime/struct.Context.html
I'm going to change the layers to make that env variable always present. I'll probably release the change this weekend.
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.
I just released the version 0.11.1 which exposes that variable again to all layers.
I'm trying the layering of runtime feature
Below code failed with
"_X_AMZN_TRACE_ID not set"
error. It seems the environment variable is unset here. How can I create a span using OpenTelemetry SDK (not tracing crate) whose trace id is retrieved from_X_AMZN_TRACE_ID
environment variable?