Skip to content

SourceMap Integration for NodejsFunction (minify esbuild bundle) #242

@MartinLoeper

Description

@MartinLoeper

Expected Behavior

I am fiddling around to get Error Tracking working using aws-cdk-v2, datadog-cdk-construct-v2 and NodejsFunction.
It would be nice to have this integrated into this construct library.

I do not know if the following setup is supported at all as there is a related issue in the dd-trace-js repository.

Expected behaviour is: When using a NodeJS Lambda function, I want error tracking in Datadog to show the source code in the stack trace (even for a handler which was bundled and minified via esbuild).

The reason why I believe this is important: The current sourceCodeIntegration does not seem to work out-of-the-box. APM error tracking cannot make sense of the NodeJS Lambda stack traces.

Actual Behavior

There is no matching source code file or source map for the bundled, minified Lambda handler /var/task/index.js.

Screenshot from 2023-12-20 17-48-27

Steps to Reproduce the Problem

  1. Use the datadog construct with .addGitCommitMetadata
  2. Use a NodejsLambda with the following bundling options:
bundling: {
        sourceMap: true,
        sourceMapMode: SourceMapMode.DEFAULT,
        sourcesContent: false,
        externalModules: [
          "dd-trace",
          "@aws-sdk/client-dynamodb",
          "@aws-sdk/client-s3",
          "@aws-sdk/lib-dynamodb",
        ],
        minify: true,
},
  1. Trigger an error span in APM for the Lambda function

Specifications

  • Datadog Lambda Layer version: 51 (extension), 101 (node)
  • Node version: 18

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions