{"library":"opentelemetry-rollup-plugin-node","title":"OpenTelemetry Rollup Plugin Node","description":"Rollup plugin that bundles OpenTelemetry Node.js core and contrib instrumentations into your code during build. Current stable version is 4.4.0, released periodically as part of the opentelemetry-node-bundler-plugins monorepo. Key differentiator: it allows bundling OpenTelemetry instrumentation for deployment in serverless or embedded scenarios where runtime patching is not possible. Requires rollup and several peer dependencies, and works alongside other rollup plugins for TypeScript and CommonJS support. Note that it only patches non-builtin modules from opentelemetry-js-contrib, so builtin modules and SDK configuration must be handled separately.","language":"javascript","status":"active","last_verified":"Mon Apr 27","install":{"commands":["npm install opentelemetry-rollup-plugin-node"],"cli":null},"imports":["import { openTelemetryPlugin } from 'opentelemetry-rollup-plugin-node'","const { openTelemetryPlugin } = await import('opentelemetry-rollup-plugin-node')","import { openTelemetryPlugin } from 'opentelemetry-rollup-plugin-node'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { rollup } from 'rollup';\nimport { openTelemetryPlugin } from 'opentelemetry-rollup-plugin-node';\nimport { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';\nimport path from 'path';\nimport typescript from '@rollup/plugin-typescript';\nimport commonjs from '@rollup/plugin-commonjs';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport json from '@rollup/plugin-json';\n\nasync function build() {\n  const bundle = await rollup({\n    input: path.normalize(__dirname + '/../src/app.ts'),\n    plugins: [\n      nodeResolve({ extensions: ['.mjs', '.js', '.json', '.ts'] }),\n      openTelemetryPlugin({\n        instrumentations: getNodeAutoInstrumentations({\n          '@opentelemetry/instrumentation-pino': {\n            logKeys: {\n              traceId: 'traceId',\n              spanId: 'spanId',\n              traceFlags: 'traceFlags',\n            },\n          },\n        }),\n      }),\n      commonjs(),\n      json(),\n      typescript({ tsconfig: path.normalize(__dirname + '/../tsconfig.json'), sourceMap: false }),\n    ],\n  });\n  await bundle.write({ file: path.normalize(__dirname + '/../dist/app.js'), format: 'cjs' });\n  await bundle.close();\n}\n\nbuild().catch(console.error);","lang":"typescript","description":"Shows how to configure rollup with the OpenTelemetry plugin, including all required rollup plugins and basic instrumentation setup.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}