Skip to content

Send from Cloudflare Workers

Export Workers logs and traces to EZGH Observability with Cloudflare's OTLP destinations, choosing the environment and application with headers.

Updated View as Markdown

Cloudflare Workers can export their logs and traces over OTLP to destinations you set up in the Cloudflare dashboard. A destination sets an endpoint and custom headers, but not resource attributes. Send the environment and application as the x-ezgh-environment and x-ezgh-application headers instead (see Service metadata).

Create an ingest key

Create a key that can send both signals:

ezgh ingest-keys create cloudflare-workers --project web \
  --action obs.logs.ingest,obs.traces.ingest > ingest-key.txt

Add the destinations

In the Cloudflare dashboard, go to Observability > Destinations and add one destination for each signal:

Field Traces Logs
Destination name ezgh-traces ezgh-logs
Destination type Traces Logs
OTLP endpoint https://obs-ingest.ezghcloud.com/v1/traces https://obs-ingest.ezghcloud.com/v1/logs

Give both destinations the same custom headers:

Header Value
authorization Bearer ezgh_ik_… (your ingest key)
x-ezgh-environment production
x-ezgh-application storefront

Workers sharing one environment and application can share these destinations. Create another pair for each further environment, such as staging.

Export from the Worker

Point the Worker’s observability settings at the destinations, then redeploy it:

// wrangler.jsonc
{
  "observability": {
    "traces": { "enabled": true, "destinations": ["ezgh-traces"] },
    "logs": { "enabled": true, "destinations": ["ezgh-logs"] }
  }
}

Each Worker’s records carry its own service.name, so you can tell several Workers apart within one application.

How the headers apply

  • The headers fill in ezgh.metadata.environment and ezgh.metadata.application only on a resource that doesn’t set them. When a resource sets its own value, that value is kept, even an invalid one (which is stored as unknown).
  • Header values follow the same rules as the attributes: they’re trimmed and lowercased, then must be 1 to 63 letters, digits, ., _ or -, starting with a letter or digit.
  • An invalid header value, or a header sent twice, rejects the whole request with 400. Check the destination’s headers if Cloudflare reports failed exports.
  • Without the headers, Workers records go to the unknown environment.
Navigation

Type to search…

↑↓ navigate↵ selectEsc close