{"record":{"id":"25357852108303b2","repo":"sveltejs/kit","slug":"tracing-is-enabled-see-the-sveltekit-plugin-trac","errorCode":null,"errorMessage":"Tracing is enabled (see the SvelteKit plugin `tracing.server` option in your vite.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api","messagePattern":"Tracing is enabled \\(see the SvelteKit plugin `tracing\\.server` option in your vite\\.config\\.js\\), but `@opentelemetry/api` is not available\\. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation\\.server\\.js`\\. For more information, see https://svelte\\.dev/docs/kit/observability#opentelemetry-api","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/exports/internal/server/telemetry.js","lineNumber":29,"sourceCode":"/**\n * The caller passes in `import('@opentelemetry/api')` so the import lives behind\n * `__SVELTEKIT_SERVER_TRACING_ENABLED__` in the bundled runtime and is eliminated\n * from builds with tracing disabled, where the package may not be installed.\n * @param {Promise<typeof import('@opentelemetry/api')>} api\n * @returns {void}\n */\nexport function init_tracing(api) {\n\totel ??= api\n\t\t.then((module) => {\n\t\t\treturn {\n\t\t\t\ttracer: module.trace.getTracer('sveltekit'),\n\t\t\t\tpropagation: module.propagation,\n\t\t\t\tcontext: module.context,\n\t\t\t\tSpanStatusCode: module.SpanStatusCode\n\t\t\t};\n\t\t})\n\t\t.catch(() => {\n\t\t\tthrow new Error(\n\t\t\t\t'Tracing is enabled (see the SvelteKit plugin `tracing.server` option in your vite.config.js), but `@opentelemetry/api` is not available. This error will likely resolve itself when you set up your tracing instrumentation in `instrumentation.server.js`. For more information, see https://svelte.dev/docs/kit/observability#opentelemetry-api'\n\t\t\t);\n\t\t});\n}\n\n/** @type {RecordSpan} */\nexport async function record_span({ name, attributes, fn }) {\n\tif (otel === null) {\n\t\treturn fn(noop_span);\n\t}\n\n\tconst { SpanStatusCode, tracer } = await otel;\n\n\treturn tracer.startActiveSpan(name, { attributes }, async (span) => {\n\t\ttry {\n\t\t\treturn await fn(span);\n\t\t} catch (error) {\n\t\t\tif (error instanceof HttpError) {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/internal/server/telemetry.js#L11-L47","documentation":"When tracing is enabled via the SvelteKit plugin's `tracing.server` option, SvelteKit imports `@opentelemetry/api` to create spans. If that package cannot be resolved, initialization fails with this error, directing you to set up tracing instrumentation (typically in `instrumentation.server.js`) which registers the provider.","triggerScenarios":"Setting `tracing.server` in `svelte.config.js`/vite plugin options without `@opentelemetry/api` installed; the package is in devDependencies but the server is bundled/deployed without it; a broken node_modules after version changes.","commonSituations":"Enabling observability in production deployments where `@opentelemetry/api` wasn't added to production dependencies; monorepo hoisting issues hiding the package; forgetting `instrumentation.server.js` setup that registers a tracer provider.","solutions":["Install the package: `npm install @opentelemetry/api` (add it to production dependencies).","Create/complete `instrumentation.server.js` to register a span processor/exporter per the SvelteKit observability docs.","If you don't want tracing, disable the `tracing.server` plugin option.","Rebuild/redeploy after installing so the server bundle can resolve the module."],"exampleFix":"// before (svelte.config.js)\nkit: { experimental: { tracing: { server: true } } }\n// after\n// terminal: npm i @opentelemetry/api\n// instrumentation.server.js\nimport { NodeSDK } from '@opentelemetry/sdk-node';\nexport const handleInstrumentation = (sdk = new NodeSDK()) => sdk.start();","handlingStrategy":"fallback","validationCode":"let api;\ntry {\n  api = await import('@opentelemetry/api');\n} catch {\n  api = null; // tracing unavailable — disable or install the package\n}\nif (!api) console.warn('tracing.server enabled but @opentelemetry/api missing');","typeGuard":null,"tryCatchPattern":"try {\n  await init_tracing();\n} catch (e) {\n  if (String(e.message).includes('@opentelemetry/api')) {\n    console.warn('Tracing disabled: install @opentelemetry/api or turn off tracing.server');\n  } else throw e;\n}","preventionTips":["Add @opentelemetry/api to production dependencies when tracing is enabled.","Create instrumentation.server.js before enabling tracing.server.","Verify the package resolves in the deployment bundle, not just locally."],"tags":["tracing","opentelemetry","missing-dependency","observability","sveltekit"],"backgroundTag":"missing-dependency","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}