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

feat: start adding support to cf pages #129

Open vanstinator opened 2 months ago

vanstinator commented 2 months ago

Fixes #96

What this PR solves / how to test:

This PR adds support for automatically instrumenting Cloudflare Pages. The code is very similar to the fetch code. I'd initially intended to combine the similar bits into a shared core, but as I started to get into those weeds I realized I didn't have a ton of context on the full set of differences between Pages and Workers, and it started to seem like keeping the code paths separate would allow for a more organic growth on the Pages instrumentation.

To test this code yourself it's as simple as wrapping a Cloudflare Pages handler in instrumentPage and passing it a valid TraceConfig.