Skip to main content

Function: startTelemetry()

@arolariu/website


@arolariu/website / instrumentation.server / startTelemetry

Function: startTelemetry()

startTelemetry(): void

Defined in: instrumentation.server.ts:597

Initializes and starts the OpenTelemetry SDK.

This should be called early in the application lifecycle, typically in the Next.js instrumentation hook (instrumentation.ts) before any other code runs.

Returns

void

Remarks

  • Starts automatic instrumentation for HTTP, fetch, and other Node.js APIs
  • Initializes trace and metric exporters
  • Sets up periodic metric export (every 60 seconds)
  • Configures batch span processing for efficiency

Throws

Will log error to console if initialization fails

Example

// In instrumentation.ts
import { startTelemetry } from '@/lib/telemetry';

export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
startTelemetry();
}
}

See

https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation

// was this page useful?