Libraries
    Preparing search index...

    Function setupOtel

    • Initializes the OpenTelemetry Node SDK with sensible defaults for the Cleverbrush framework.

      This must be called before any instrumented modules are imported — typically via node --import ./telemetry.js entrypoint.js.

      Configures W3C Trace Context propagation, OTLP/HTTP exporters for traces, logs, and metrics, and the resource attributes that identify the service in observability backends.

      Parameters

      • config: OtelConfig

        service identity and exporter configuration

      Returns OtelHandle

      a handle exposing shutdown() and the underlying SDK

      // telemetry.ts — loaded via `node --import ./telemetry.js`
      import { setupOtel } from '@cleverbrush/otel';
      import { outboundHttpInstrumentations, runtimeMetrics } from '@cleverbrush/otel/instrumentations';

      export const otel = setupOtel({
      serviceName: 'todo-backend',
      serviceVersion: '1.0.0',
      environment: process.env.NODE_ENV,
      otlpEndpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
      instrumentations: [...outboundHttpInstrumentations(), runtimeMetrics()],
      });

      process.on('SIGTERM', () => otel.shutdown());