@grand-board/otel-cloudflare - v6.11.0
    Preparing search index...

    Function initOTLP

    • Initialize OTLP collectors for a request

      Call this at the beginning of your request handler. Returns a FlushContext that you should call flush() on at the end.

      Parameters

      • env: Record<string, unknown> | undefined

        Environment variables (used to auto-detect OTLP config if configOverride not provided)

      • serviceName: string

        Service name for telemetry

      • OptionalconfigOverride: OTLPExporterConfig | null

        Optional explicit OTLP config (skips env detection if provided)

      Returns FlushContext

      // SvelteKit hooks.server.ts
      import { initOTLP, type FlushContext } from '@grand-board/otel-cloudflare';

      export async function handle({ event, resolve }) {
      const ctx = initOTLP(event.platform?.env, 'my-service');

      try {
      return await resolve(event);
      } finally {
      // Use waitUntil if available, otherwise await
      if (event.platform?.context?.waitUntil) {
      event.platform.context.waitUntil(ctx.flush());
      } else {
      await ctx.flush();
      }
      }
      }