Skip to content

tracing field missing from Lambda extension INVOKE event #109

Open
@ramosbugs

Description

@ramosbugs

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.

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