Skip to content

Traces, logs and request ids

Metrics are in metrics, and what to alert on in alerts. This page is about the rest.

Every answer from the API carries x-request-id. It is the trace id of the request’s invocation: the id its logs carry in Workers Logs, and the trace id of its spans, in the API and in the engine and containers it calls. A request that is not traced (see sampling below) still has it on its logs. Where the platform gives no trace id, it is a random id of the same shape, 32 hex digits.

An internal error is logged with its request id, and fiber prints it after a server’s failure:

fiber: internal error (request 4bf92f3577b34da6a3ce929d0e0e4736)

To find that request, filter Workers Logs or traces on the trace id, or search for the id in your own backend once logs are exported.

The API, engine and containers Workers are traced: each request, the calls it makes to D1, R2 and Durable Objects, and its calls from one Worker to another, as one trace. One request in ten is traced (head_sampling_rate: 0.1 under observability.traces in each wrangler.jsonc). Set it from 0 to 1; the choice is made as a request arrives, and one that is not traced is not slowed.

What a span keeps: URLs, header names but not their values, methods, statuses and timings. Each Worker has redact_query_string on, which takes query strings out of the URLs of the requests it receives. The URLs of requests a Worker sends are kept whole, path and query: an http_request task’s address among them, so a credential in that address is in its traces (tasks). The API’s invocation logs stay off, since they would hold header values.

Workers export traces and logs to any destination that accepts OTLP over HTTP with JSON: Honeycomb, Grafana Cloud, Axiom, Sentry, or a collector of your own.

  1. In the Cloudflare dashboard, under Observability > Destinations, add one destination for traces and one for logs, with your provider’s endpoint and authentication header.

  2. Name them in each Worker’s wrangler.jsonc (apps/api, apps/engine, apps/containers), as you do its database id:

    "observability": {
    // ...as it is
    "traces": { "enabled": true, "head_sampling_rate": 0.1, "destinations": ["fiber-traces"] },
    "logs": { "enabled": true, "destinations": ["fiber-logs"] }
    }

    Keep the API’s "invocation_logs": false and "redact_query_string": true when you add these.

  3. Deploy. Data takes a few minutes to arrive.

Traces and logs are also kept in Cloudflare, where they are billed by volume. Add "persist": false to traces or logs to send them only to your destination.

  • The runner’s steps are not joined to the server’s trace, as the Rust agent’s were by a traceparent in the offer: a Worker cannot yet hand its trace context to a service outside Cloudflare.
  • Exported metrics: Workers do not export metrics over OTLP. Scrape /metrics instead.