Cloudflare Workers OpenTelemetry

Send logs and traces in 5 minutes

Export OpenTelemetry logs and traces from your Cloudflare Workers to Better Stack. Cloudflare's built-in Workers observability sends them for you, so no instrumentation code is required.

Create a source

Create an OpenTelemetry source and keep the tab open. You'll need its Ingesting host and Source token.

Add two Cloudflare destinations

In the Cloudflare dashboard, go to Workers & Pages → Observability → Telemetry and click Add destination once for traces and once for logs:

Traces Logs
Destination name: betterstack-traces
Destination type: Traces
OTLP endpoint: https://$INGESTING_HOST/v1/traces
Custom header: "Authorization" with value "Bearer $SOURCE_TOKEN"
Destination name: betterstack-logs
Destination type: Logs
OTLP endpoint: https://$INGESTING_HOST/v1/logs
Custom header: "Authorization" with value "Bearer $SOURCE_TOKEN"


Enable observability in your Worker

Add the observability block to your wrangler.jsonc. The destinations names must match the destinations you just created:

wrangler.jsonc
{
  "observability": {
    "traces": { "enabled": true, "destinations": ["betterstack-traces"], "head_sampling_rate": 1.0, "persist": false },
    "logs":   { "enabled": true, "destinations": ["betterstack-logs"],   "head_sampling_rate": 1.0, "persist": false }
  }
}

Want to sample or keep a copy in Cloudflare?

head_sampling_rate: 1.0 exports every trace. Lower it to sample in production. persist: false sends data to Better Stack only. Set it to true to also keep logs and traces in Cloudflare.

Deploy your Worker

Deploy your Worker
npx wrangler deploy

View your logs and traces

Open Better Stack → Live tail. Your first traces and logs arrive within a minute or two. Send requests to your Worker to see a span per request, each with its console.log lines linked to the trace.

Need help?

Please let us know at hello@betterstack.com.
We're happy to help! 🙏