Skip to content

Commit 433dadb

Browse files
docs(configuration): pair threads.preload with preloadRequire for dd-trace
`dd-trace/register.js` only installs the ESM loader hooks; it never calls `init()`. Configuring `threads.preload: dd-trace/register.js` alone therefore leaves the tracer uninitialized - spans are created and carry plausible trace ids, but they are no-ops and nothing is exported, so the failure is silent. `dd-trace/init` (`threads.preloadRequire`) is the entry that starts the tracer. Replace the claim that `dd-trace/init` "only covers the main thread", show both keys together in the dd-trace example, and cross-reference the two bullets. Behavior is scoped to dd-trace 6.x, since a future major could change `register.js`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent efa2240 commit 433dadb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

reference/configuration/options.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ threads:
6565
- `maxHeapMemory` — Heap limit per thread (MB)
6666
- `heapSnapshotNearLimit` — Write a `.heapsnapshot` file when a thread nears its heap limit (loadable in Chrome DevTools Memory tab); _Default_: `false`. See [Worker Thread Debugging](./debugging.md#heap-snapshots-near-the-limit)
6767
- `debug` — Enable Node.js inspector; sub-options: `port`, `startingPort`, `host`, `waitForDebugger`. See [Worker Thread Debugging](./debugging.md)
68-
- `preload` <VersionBadge version="v5.2.0" /> — Module, or list of modules, to load (via Node's `--import`) before any Harper or application module on each worker thread. Intended for instrumentation/APM agents that must load first to instrument subsequent module loads. Use the agent's ESM/register entry — e.g. `dd-trace/register.js`, which registers the loader hooks that instrument worker threads (where Harper runs its work); the plain `dd-trace/init` (`--require`) entry only covers the main thread. Bare specifiers resolve against the `node_modules` of your installed [components](../components/overview.md) — so the agent can be shipped as a dependency of a deployed component — and absolute paths are also accepted. Applies to worker threads only (not under Bun).
68+
- `preload` <VersionBadge version="v5.2.0" /> — Module, or list of modules, to load (via Node's `--import`) before any Harper or application module on each worker thread. Intended for instrumentation/APM agents that must load first to instrument subsequent module loads. Use the agent's ESM/register entry — e.g. `dd-trace/register.js`, which installs the ESM loader hooks that produce automatic instrumentation for `import`-loaded modules. As measured on dd-trace 6.x, that entry only registers the loader hooks and never calls `init()`, so `preload` on its own leaves the tracer uninitialized: it still hands out spans with plausible trace ids, but they are no-ops and nothing is ever exported. Pair it with `preloadRequire: dd-trace/init`, which is the entry that actually starts the tracer. Bare specifiers resolve against the `node_modules` of your installed [components](../components/overview.md) — so the agent can be shipped as a dependency of a deployed component — and absolute paths are also accepted. Applies to worker threads only (not under Bun).
6969

7070
```yaml
7171
threads:
72-
preload: dd-trace/register.js
72+
preloadRequire: dd-trace/init # starts the tracer
73+
preload: dd-trace/register.js # ESM loader hooks for automatic instrumentation
7374
```
7475

7576
Or several modules:
@@ -81,11 +82,11 @@ threads:
8182
- /opt/instrumentation/agent.mjs
8283
```
8384

84-
- `preloadRequire` <VersionBadge version="v5.2.0" /> — Same as `preload`, but loads modules via Node's `--require` (CommonJS) instead of `--import`. Use this for agents that document the `--require` path and do not need ESM loader hooks (e.g. `dd-trace/init`, Dynatrace OneAgent). Same resolution rules as `preload`.
85+
- `preloadRequire` <VersionBadge version="v5.2.0" /> — Same as `preload`, but loads modules via Node's `--require` (CommonJS) instead of `--import`. Use this for agents that document the `--require` path (e.g. `dd-trace/init`, Dynatrace OneAgent). Same resolution rules as `preload`. For dd-trace, `dd-trace/init` is the entry that starts the tracer, and it does not register the ESM loader hooks — keep `preload: dd-trace/register.js` alongside it, as shown under `preload` above.
8586

8687
```yaml
8788
threads:
88-
preloadRequire: dd-trace/init
89+
preloadRequire: dd-trace/init # starts the tracer; pair with preload (see above)
8990
```
9091

9192
---

0 commit comments

Comments
 (0)