evanderkoogh / otel-cf-workers

An OpenTelemetry compatible library for instrumenting and exporting traces for Cloudflare Workers
BSD 3-Clause "New" or "Revised" License
208 stars 39 forks source link

feature request: export const unwrappedFetch = unwrap(fetch) #79

Closed Code-Hex closed 2 months ago

Code-Hex commented 6 months ago

Thank you for the wonderful library. I am currently writing an Exporter myself to send Span to GCP.

As you can see from https://cloud.google.com/trace/docs/reference/v2/rest/v2/projects.traces/batchWrite, an access token is required to send spans. To obtain the access token, a fetch operation needs to be performed in advance.

In this library, before setting up the Exporter, it recursively performs fetch wrapping for the client, as shown in the image below, infinitely. I would like to prevent this.

  1. Please provide a solution as described in the title.
  2. After setting up the Exporter, wrap the client's fetch.

I would appreciate it if you could address either of the above options.

スクリーンショット 2023-12-20 17 17 29