Skip to main content

Function: stopTelemetry()

@arolariu/website


@arolariu/website / instrumentation.server / stopTelemetry

Function: stopTelemetry()

stopTelemetry(): Promise<void>

Defined in: instrumentation.server.ts:628

Gracefully shuts down the OpenTelemetry SDK.

Flushes any pending telemetry data and cleanly terminates exporters. This ensures no data loss when the application terminates.

Returns

Promise<void>

Promise that resolves when shutdown is complete

Remarks

  • Flushes all pending spans and metrics
  • Closes connections to OTLP endpoints
  • Stops all instrumentation
  • Should be called before process exit

Throws

Will log error to console if shutdown fails or times out

Example

// Manual shutdown
import { stopTelemetry } from '@/lib/telemetry';

process.on('SIGTERM', async () => {
await stopTelemetry();
process.exit(0);
});

See

https://opentelemetry.io/docs/specs/otel/trace/sdk/#shutdown

// was this page useful?