WORK-IN-PROGRESS feat(lambda): migrate datadog-lambda-js into dd-trace-js as a plugin#7778
WORK-IN-PROGRESS feat(lambda): migrate datadog-lambda-js into dd-trace-js as a plugin#7778joeyzhao2018 wants to merge 3 commits intomasterfrom
Conversation
Consolidates all server-side Lambda tracing functionality from the standalone datadog-lambda-js repo into dd-trace-js as a proper plugin, eliminating the double-wrapping problem and using AWS_LAMBDA_EXEC_WRAPPER for clean auto-instrumentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7778 +/- ##
==========================================
- Coverage 80.42% 76.27% -4.16%
==========================================
Files 741 647 -94
Lines 32177 27386 -4791
==========================================
- Hits 25878 20888 -4990
- Misses 6299 6498 +199
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overall package sizeSelf size: 5.06 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
The Agent Extension layer ships its own /opt/datadog_wrapper, which overwrites the dd-trace layer's wrapper. Move the wrapper into /opt/nodejs/dd_trace_wrapper to avoid the collision. Also fix handler instrumentation to use Module._load instead of addHook, since the Lambda runtime loads handlers by file path (not npm package name). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
BenchmarksBenchmark execution time: 2026-03-14 04:12:50 Comparing candidate commit b6ed1e9 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 228 metrics, 32 unstable metrics. |
…ixes The nodejs22.x Lambda runtime uses ESM import() to load handlers, which bypasses Module._load patching entirely. Switch to overriding _HANDLER in the wrapper script to point to a handler-wrapper module that loads the original handler, wraps it with tracing channel events, and re-exports it. Also fixes several issues found during real-world Lambda deployment: - Register lambda plugin explicitly in PluginManager (no addHook flow) - Add DD_TRACE_LAMBDA_ENABLED to supported-configurations.json - Add lambda schema to v0/v1 serverless service naming definitions - Don't propagate X-Ray Sampled=0 as sampling priority -1 unless DD_MERGE_XRAY_TRACES is enabled (was dropping all traces) - Wrap asyncStart in try/finally to guarantee span.finish() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Consolidates all server-side Lambda tracing functionality from the standalone datadog-lambda-js repo into dd-trace-js as a proper plugin, eliminating the double-wrapping problem and using AWS_LAMBDA_EXEC_WRAPPER for clean auto-instrumentation.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
What does this PR do?
Motivation
Additional Notes