autotel
Version:
Write Once, Observe Anywhere
1 lines • 1.43 kB
Source Map (JSON)
{"version":3,"sources":["../src/register.ts"],"names":["register"],"mappings":";;;;;;AAoCAA,iBAAA,CAAS,yCAAA,EAA2C,8PAAe,CAAA","file":"register.cjs","sourcesContent":["/**\n * ESM instrumentation registration for Node.js 18.19+\n *\n * This module registers the OpenTelemetry ESM loader hook using the modern\n * node:module register() API. This eliminates the need for NODE_OPTIONS or\n * --experimental-loader flags.\n *\n * Usage in instrumentation.mjs:\n * ```typescript\n * import 'autotel/register'; // MUST be first import!\n * import { init } from 'autotel';\n *\n * init({\n * service: 'my-app',\n * instrumentations: [...], // or autoInstrumentations: ['express', 'http', 'pino']\n * });\n * ```\n *\n * Then run:\n * ```bash\n * node --import ./instrumentation.mjs src/index.js\n * # or with tsx:\n * tsx --import ./instrumentation.mjs src/index.ts\n * ```\n *\n * No NODE_OPTIONS or --experimental-loader needed!\n *\n * @requires Node.js 18.19.0 or later\n * @see https://github.com/open-telemetry/opentelemetry-js/blob/main/doc/esm-support.md\n * @see https://nodejs.org/api/module.html#moduleregisterspecifier-parenturl-options\n */\n\nimport { register } from 'node:module';\n\n// Use the official OpenTelemetry instrumentation hook which wraps import-in-the-middle\n// This ensures proper integration with OTel's instrumentation system\nregister('@opentelemetry/instrumentation/hook.mjs', import.meta.url);\n"]}