Description
Describe the bug
I am trying to use the OpenTelemetry Lambda layers in a Lambda Container image.
When I invoke the Lambda function in AWS, the function executes successfully, however, I do not see any of the spans from the instrumentation of the Lambda. It appears that the Collector extension is not exporting span data to X-Ray or any other backend.
Steps to reproduce
I have created a repository to reproduce the issue at https://github.com/gotgenes/lambda-opentelemetry-docker.
The repository includes the following:
- A Node.js Lambda function implemented in TypeScript.
- A Dockerfile to build the Lambda container image from the Node.js v22 Lambda base image with the OpenTelemetry Lambda layers.
- A Docker Compose file to run the Lambda container locally with Docker, along with an otel-tui sidecar container to view the telemetry.
- A CDK app to create the ECR repository and deploy the Lambda function.
The steps to reproduce the issue are as follows:
-
Clone the repository.
-
Set the environment variables:
export AWS_PROFILE=$YOUR_PROFILE export COMPOSE_BAKE=true
-
Log in to AWS CLI:
npm run login
-
Create the ECR repository:
npm run deploy-ecr
-
Build and push the Docker image to ECR, and deploy the Lambda function:
npm run build-publish-deploy
-
Invoke the Lambda function, using the Function URL output during the CDK deployment:
curl -XPOST -i --json '{}' $LAMBDA_FUNCTION_URL
-
Observe the trace for the Lambda function in CloudWatch has no spans for the
fetch
call made in the Lambda function.
Please see the repository's README for detailed instructions.
What did you expect to see?
I expected to see the spans from the OpenTelemetry instrumentation of the Lambda function in the trace in CloudWatch.
Specifically, I expected to see a span named GET
from the fetch
call made in the Lambda function, which would indicate that the OpenTelemetry Collector extension is correctly exporting spans from the auto-instrumentation to X-Ray. Such a span would look like the following example from otel-tui:
What did you see instead?
The only spans I see in the trace in CloudWatch are the ones from the Lambda function initialization, invocation, and overhead. None of these seem to contain data internal to the Lambda, itself, but part of the Lambda runtime machinery:
What version of collector/language SDK version did you use?
- Collector extension layer version:
v0.15.0
- Node.js layer version:
v0.14.0
What language layer did you use?
JavaScript/Node.js (implemented in TypeScript)
Additional context
While I appreciate this project providing extension layers for the collector and language SDKs that can be accessed for ZIP file distributions, it seems to me that AWS wants to push users towards using container images for Lambda functions. Therefore, I think it would be beneficial to support the OpenTelemetry Lambda layers in container images as well. That might look like also providing base images with the OpenTelemetry Lambda layers included, or at least documenting how to use the layers in a custom Dockerfile. The purpose of my repository is to demonstrate how to do that, but it currently does not work as expected.