Skip to content

docs(instrumentation): register ESM hooks via module.register() with --import - #7034

Open
The-Alchemist wants to merge 2 commits into
open-telemetry:mainfrom
The-Alchemist:docs/esm-import-register-hook
Open

docs(instrumentation): register ESM hooks via module.register() with --import#7034
The-Alchemist wants to merge 2 commits into
open-telemetry:mainfrom
The-Alchemist:docs/esm-import-register-hook

Conversation

@The-Alchemist

@The-Alchemist The-Alchemist commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • follow up from ESM support documentation update: use --import for Node v24 #6909

  • --import @opentelemetry/instrumentation/hook.mjs does not register exported loader hooks, so ESM instrumentation is silently skipped.

  • Document a user-owned register-otel-hook.mjs preload that calls module.register('@opentelemetry/instrumentation/hook.mjs', import.meta.url) and use that with --import on Node 24+.

  • Add a child-process integration test covering --experimental-loader (patched), bare --import hook.mjs (unpatched), and --import of the module.register() preload (patched).

We verify's @JacksonWeber concern that --import of hook.mjs may silently disable ESM instrumentation.

Test plan

  • npx mocha test/node/HookCliRegistration.test.ts in @opentelemetry/instrumentation
  • npm test in @opentelemetry/instrumentation
  • npm run lint in @opentelemetry/instrumentation
  • Confirm CI on Node 18/20/22/24/26

@github-actions

Copy link
Copy Markdown

Welcome, contributor! Thank you for your contribution to opentelemetry-js.

Important reminders:

…--import

--import of hook.mjs does not install loader hooks, so ESM instrumentation
is silently skipped. Document a register() preload and add a child-process
test covering loader, bare --import, and module.register() startup.

Signed-off-by: Karl Pietrzak <karl@medplum.com>
@The-Alchemist
The-Alchemist force-pushed the docs/esm-import-register-hook branch from d46c055 to c6b09d7 Compare August 25, 2026 22:39
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 2, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-03 20:21 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@The-Alchemist
The-Alchemist marked this pull request as ready for review September 2, 2026 16:55
@The-Alchemist
The-Alchemist requested a review from a team as a code owner September 2, 2026 16:55
Signed-off-by: Karl Pietrzak <karl@medplum.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants