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

    Function tracedFetch

    • Create an instrumented fetch function that automatically:

      • Creates a CLIENT span for each outgoing request
      • Injects traceparent header for distributed tracing
      • Records HTTP attributes (method, URL, status code)

      Parameters

      • baseFetch: {
            (
                input: RequestInfo<unknown, CfProperties<unknown>> | URL,
                init?: RequestInit<RequestInitCfProperties>,
            ): Promise<Response>;
            (
                input: string | Request<unknown, CfProperties<unknown>> | URL,
                init?: RequestInit<CfProperties<unknown>>,
            ): Promise<Response>;
        } = globalThis.fetch

      Returns (
          input: RequestInfo<unknown, CfProperties<unknown>> | URL,
          init?: RequestInit<CfProperties<unknown>>,
          options?: TracedFetchOptions,
      ) => Promise<Response>

      const fetch = tracedFetch();

      // Use like regular fetch - tracing happens automatically
      const response = await fetch('https://api.example.com/users');
      // Skip tracing for specific requests
      const fetch = tracedFetch();
      const response = await fetch('https://api.example.com/health', {}, { skipTracing: true });