{"record":{"id":"81541a2d9c9988fc","repo":"pydantic/monty","slug":"at-least-one-opentelemetry-component-is-required","errorCode":null,"errorMessage":"at least one OpenTelemetry component is required","messagePattern":"at least one OpenTelemetry component is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/monty-js/ts/telemetry.ts","lineNumber":176,"sourceCode":"    if (invoked) {\n      throw error\n    }\n    return callback()\n  }\n}\n\n/**\n * Instrument Monty with standard OpenTelemetry components.\n *\n * Installation is process-wide and must happen before creating a pool. Each\n * signal is independently optional.\n */\nexport function instrumentTelemetry(value: TelemetryComponents): void {\n  if (owner !== undefined) {\n    throw new Error('Monty telemetry is already configured')\n  }\n  if (value.tracer === undefined && value.meter === undefined && value.logger === undefined) {\n    throw new Error('at least one OpenTelemetry component is required')\n  }\n  activate(directOwner, value)\n}\n\n/** Wait until telemetry queued by the native pool has reached JavaScript. */\nexport async function flushTelemetry(): Promise<void> {\n  await flushNativeTelemetry()\n  if (!acceptingTelemetry) {\n    components = undefined\n    spans.clear()\n    instruments.clear()\n  }\n}\n\n/**\n * OpenTelemetry instrumentation for use with `NodeSDK` and compatible SDKs.\n *\n * Adding an instance to an SDK's `instrumentations` array explicitly enables","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-js/ts/telemetry.ts#L158-L194","documentation":"`instrumentTelemetry` requires at least one OpenTelemetry component: a tracer, a meter, or a logger. If all three are undefined the call is a no-op configuration, so the function throws this Error to signal the misconfiguration rather than installing nothing.","triggerScenarios":"Calling `instrumentTelemetry({})` or passing an object whose `tracer`, `meter`, and `logger` properties are all undefined — e.g. building the object conditionally from environment variables where none were set.","commonSituations":"Config-driven setup where `OTEL_TRACER`/`OTEL_METER`/`OTEL_LOGGER` flags are all absent or disabled; a refactor that renamed the component keys so the values no longer land on `tracer`/`meter`/`logger`; passing `undefined` from an optional getter.","solutions":["Pass at least one component: `instrumentTelemetry({ tracer, meter, logger })` with at least one defined.","If telemetry is optional, skip the call entirely when no components are configured instead of calling it with an empty object.","Verify the property names (`tracer`, `meter`, `logger`) match your constructed components; renamed variables silently leave all fields undefined."],"exampleFix":"// before\ninstrumentTelemetry({}) // throws\n\n// after\nconst components = { tracer: getTracer() }\nif (components.tracer || components.meter || components.logger) {\n  instrumentTelemetry(components)\n}","handlingStrategy":"validation","validationCode":"function hasAnyComponent(v: TelemetryComponents): boolean {\n  return v.tracer !== undefined || v.meter !== undefined || v.logger !== undefined\n}\n// call only if hasAnyComponent(components)","typeGuard":"function isTelemetryComponentsConfigured(v: TelemetryComponents): boolean {\n  return [v.tracer, v.meter, v.logger].some(c => c !== undefined)\n}","tryCatchPattern":"try {\n  instrumentTelemetry(components)\n} catch (err) {\n  if (err instanceof Error && err.message === 'at least one OpenTelemetry component is required') {\n    console.warn('telemetry disabled: no components configured')\n  } else {\n    throw err\n  }\n}","preventionTips":["Gate the instrumentation call behind a check that at least one component exists.","Make telemetry opt-in: skip the call entirely when nothing is configured.","Keep component construction close to the call so renamed/undefined values are caught early."],"tags":["typescript","telemetry","opentelemetry","config"],"backgroundTag":"missing-required-config-field","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}