perf(runtime): use dd-trace loader registration - #819
Merged
Conversation
|
Direct Module.register() forces a loader worker even when the installed tracer supports in-process hooks. Loading the function-local tracer registration entry preserves preload and older-runtime fallbacks. Paired Lambda trials reduced module load by 79.549 ms and startup total by 65.788 ms (21.47%).
Function-local dd-trace v5.5 has loader-hook.mjs but no register.js. The fallback preserves ESM instrumentation while newer tracers use their optimized registration entry point.
BridgeAR
force-pushed
the
BridgeAR/2026-08-28-loader-registration
branch
from
September 1, 2026 15:06
2faef26 to
457adeb
Compare
joeyzhao2018
added a commit
that referenced
this pull request
Sep 2, 2026
Three conflicts, all resolved as unions of both sides: - src/handler.mjs: main (#819) moved the ESM loader-hook registration out of handler.mjs into initTracer() in src/runtime/module_importer.js, so this branch's copy of esmLoaderAlreadyRegistered() and the Module.register() block are dropped in favor of main's. Kept this branch's new DD_TRACE_STARTUP_LOGS default. dd-trace 6.12.0 ships both register.js and loader-hook.mjs, so main's registration path works on the v6 line. - integration_tests/container/cjs/Dockerfile: kept this branch's DD_TRACE_VERSION build-arg + `npm pkg set` override alongside main's `COPY package.json *.js` for the new manual-wrap fixture handlers. - integration_tests/container/cjs/package.json: main's axios pin plus this branch's dd-trace 6.12.0. main's integration_tests_local/run.sh already probes for scripts/install_deps.sh and scripts/dd_trace_versions.sh and passes --build-arg DD_TRACE_VERSION, so the new local harness picks up the per-runtime tracer split without changes. Verified: yarn build, yarn test (638 tests, 52 suites — including main's new src/handler.spec.ts and src/runtime/module-importer.spec.ts), yarn lint and yarn check-formatting all pass against dd-trace 6.12.0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Load the function-local
dd-traceregistration entry during tracer initialization instead of registering another loader hook from the Lambda wrapper.Direct
Module.register()creates a loader worker and synchronous startup communication. The canonical entry can select in-process hooks. Older function-local tracers withoutregister.jsretain the direct fallback.Paired Lambda trials reduced module load by 79.549 ms and startup total by 65.788 ms (21.47%). A fresh local Node 22.23.2 benchmark across 40 alternating pairs reduced module load by 45.881 ms and startup total by 45.264 ms (15.54%).