Cloudflare Workers
Overview

Cloudflare Workers

Cloudflare Workers has built-in observability that can export traces and logs via OTLP. No SDK or code changes are needed in your Worker — just configure a destination in the Cloudflare dashboard and enable it in your wrangler.jsonc.

Traces

Step 1: Create a traces destination in the Cloudflare dashboard

Navigate to Compute (Workers) → Observability → Destinations, then click "+ Add Destination".

Cloudflare Observability Destinations

Fill in the following fields:

  • Destination Type: Traces
  • OTLP Endpoint: https://cloud.tracewayapp.com/api/otel/v1/traces (or your self-hosted equivalent)
  • Destination Name: traceway-traces
  • Custom Header: Authorization = Bearer <project_token>

Replace <project_token> with your project token from the Traceway dashboard under Project Settings.

Add Destination form

Step 2: Enable traces in wrangler.jsonc

Add the observability.traces configuration to your wrangler.jsonc, referencing the destination name you created above:

{
  "observability": {
    "traces": {
      "enabled": true,
      "destinations": ["traceway-traces"],
      "head_sampling_rate": 1
    }
  }
}

Set head_sampling_rate to a value between 0 and 1 to control what fraction of requests are traced. Use 1 to trace every request.

Logs

Logs work exactly like traces — create a second destination in the dashboard, add a second block to wrangler.jsonc, and redeploy. No Worker code changes.

Step 1: Create a logs destination in the Cloudflare dashboard

Back in Workers → Observability → Destinations, click "+ Add Destination" a second time and fill in:

  • Destination Type: Logs
  • OTLP Endpoint: https://cloud.tracewayapp.com/api/otel/v1/logs (or your self-hosted equivalent)
  • Destination Name: traceway-logs
  • Custom Header: Authorization = Bearer <project_token>

Use the same project token as the traces destination.

Step 2: Enable logs in wrangler.jsonc

Add the observability.logs block alongside observability.traces:

{
  "observability": {
    "traces": {
      "enabled": true,
      "destinations": ["traceway-traces"],
      "head_sampling_rate": 1
    },
    "logs": {
      "enabled": true,
      "destinations": ["traceway-logs"],
      "head_sampling_rate": 1,
      "persist": false
    }
  }
}
  • head_sampling_rate (0 to 1) controls what fraction of logs are exported. Use 1 to export every log.
  • persist: false disables Cloudflare's own dashboard log storage to reduce billing when Traceway is your primary destination. Set to true (or omit) if you still want to view logs in the Cloudflare dashboard as well.

When both traces and logs are enabled, each log carries the trace_id and span_id of the request that produced it — so Traceway shows those logs on the matching trace detail page automatically.

Deploy

Deploy your Worker:

npx wrangler deploy

Traces and logs will appear in Traceway automatically.

See OTel Logs for the full OTLP logs mapping and severity reference.