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

tracing field missing from Lambda extension INVOKE event #109

Open
ramosbugs opened this issue Dec 21, 2023 · 0 comments
Open

tracing field missing from Lambda extension INVOKE event #109

ramosbugs opened this issue Dec 21, 2023 · 0 comments

Comments

@ramosbugs
Copy link

The AWS Lambda Extensions API seems to set the tracing field in the INVOKE event for Lambda extensions even if X-Ray active tracing is disabled for the Lambda function and the requesting service (e.g., API Gateway) doesn't provide tracing headers. It's unclear where the trace ID originates, but I confirmed that it's present even when X-Ray is disabled. When I searched the trace ID in the X-Ray console, it didn't find anything, suggesting that the AWS Lambda service generates a new trace ID when none is provided.

However, the emulator omits this field when the request doesn't include an X-Amzn-Trace-Id header:

Tracing: model.NewXRayTracing(req.TraceID),

func NewXRayTracing(value string) *Tracing {
if len(value) == 0 {
return nil
}

This behavior breaks compatibility with the AWS Lambda Rust Runtime, which expects the tracing field (cc @calavera):
https://github.com/awslabs/aws-lambda-rust-runtime/blob/ab3b809d63fad05369596d17ad4fc449f7035e5e/lambda-extension/src/events.rs#L23

When locally testing Lambda extensions using the Rust runtime and the AWS SAM CLI's sam local command, extensions fail with a "missing field tracing" error. The same extensions work fine in production.

Since this incompatibility is due to a behavioral difference between the AWS Lambda service in production and the emulator, I think it's ultimately a bug in the emulator, rather than the Rust runtime being overly strict.

I'd suggest changing the NewXRayTracing function to generate a trace ID when none is provided, rather than returning nil.

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

No branches or pull requests

1 participant