Registry /
observability / opentelemetry-rollup-plugin-node
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
openTelemetryPlugin
✓ import { openTelemetryPlugin } from 'opentelemetry-rollup-plugin-node'
✗ const openTelemetryPlugin = require('opentelemetry-rollup-plugin-node')
ESM-only; the package does not provide a CommonJS export. Use dynamic import if needed in CJS context.
openTelemetryPlugin
✓ const { openTelemetryPlugin } = await import('opentelemetry-rollup-plugin-node')
✗ const openTelemetryPlugin = require('opentelemetry-rollup-plugin-node')
For CommonJS projects, use dynamic import. The package does not ship CJS.
openTelemetryPlugin
✓ import { openTelemetryPlugin } from 'opentelemetry-rollup-plugin-node'
✗ import defaultExport from 'opentelemetry-rollup-plugin-node'
This is a named export, not a default export. Default import will give undefined.
Shows how to configure rollup with the OpenTelemetry plugin, including all required rollup plugins and basic instrumentation setup.
import { rollup } from 'rollup';
import { openTelemetryPlugin } from 'opentelemetry-rollup-plugin-node';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import path from 'path';
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
async function build() {
const bundle = await rollup({
input: path.normalize(__dirname + '/../src/app.ts'),
plugins: [
nodeResolve({ extensions: ['.mjs', '.js', '.json', '.ts'] }),
openTelemetryPlugin({
instrumentations: getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-pino': {
logKeys: {
traceId: 'traceId',
spanId: 'spanId',
traceFlags: 'traceFlags',
},
},
}),
}),
commonjs(),
json(),
typescript({ tsconfig: path.normalize(__dirname + '/../tsconfig.json'), sourceMap: false }),
],
});
await bundle.write({ file: path.normalize(__dirname + '/../dist/app.js'), format: 'cjs' });
await bundle.close();
}
build().catch(console.error);
Errors
Common errors & fixes
Error: Must use import to load ES Module: /path/to/node_modules/opentelemetry-rollup-plugin-node/dist/index.js
Attempting to require() an ES Module with CommonJS require().
fixChange to dynamic import: const { openTelemetryPlugin } = await import('opentelemetry-rollup-plugin-node'); TypeError: openTelemetryPlugin is not a function
Default import used instead of named import, resulting in undefined.
fixUse named import: import { openTelemetryPlugin } from 'opentelemetry-rollup-plugin-node'; Error: Cannot find module '@opentelemetry/auto-instrumentations-node'
Missing required peer dependency.
fixInstall the package: npm install @opentelemetry/auto-instrumentations-node
Audit
Dependencies
rollupoptionalpeer dependency required at runtime
@opentelemetry/auto-instrumentations-nodeoptionalrecommended package to get instrumentations to pass to plugin