Cloudflare Workers Observability

Learn how to set up Cloudflare Workers Observability to forward logs and traces data to Sentry.

Cloudflare Workers supports exporting OpenTelemetry (OTEL)-compliant data to send logs and traces to Sentry.

  • Logs: Application logs including console.log() output and system-generated logs
  • Traces: Traces showing request flows through your Worker and connected services

Before you begin, ensure you have:

  • A deployed Worker that you want to monitor
  • A Sentry project you want to send data to

To set up a destination in the Cloudflare dashboard, navigate to your Cloudflare account's Workers Observability section. Then click Add destination and configure either a traces or logs destination.

To configure your logs destination, click Add destination and configure the following:

  1. Destination Name: sentry-logs (or any descriptive name)
  2. Destination Type: Select Logs
  3. OTLP Endpoint: Your Sentry OTLP logs endpoint (e.g., https://{HOST}/api/{PROJECT_ID}/integration/otlp/v1/logs)
Copied
___OTLP_LOGS_URL___
  1. Custom Headers: Add the Sentry authentication header:
    • Header name: x-sentry-auth
    • Header value: sentry sentry_key={SENTRY_PUBLIC_KEY} where {SENTRY_PUBLIC_KEY} is your Sentry project's public key
Copied
sentry sentry_key=___PUBLIC_KEY___

You can find your Sentry OTLP logs endpoint and authentication header value in your Sentry Project Settings under Client Keys (DSN) > OpenTelemetry (OTLP) under the OTLP Logs Endpoint section.

To configure your traces destination, click Add destination and configure the following:

  1. Destination Name: sentry-traces (or any descriptive name)
  2. Destination Type: Select Traces
  3. OTLP Endpoint: Your Sentry OTLP traces endpoint (e.g., https://{HOST}/api/{PROJECT_ID}/integration/otlp/v1/traces)
Copied
___OTLP_TRACES_URL___
  1. Custom Headers: Add the Sentry authentication header:
    • Header name: x-sentry-auth
    • Header value: sentry sentry_key={SENTRY_PUBLIC_KEY} where {SENTRY_PUBLIC_KEY} is your Sentry project's public key
Copied
sentry sentry_key=___PUBLIC_KEY___

You can find your Sentry OTLP traces endpoint and authentication header value in your Sentry Project Settings under Client Keys (DSN) > OpenTelemetry (OTLP) under the OTLP Traces Endpoint section.

With your destinations created in the Cloudflare dashboard, update your Worker's configuration to enable telemetry export.

wrangler.toml
Copied
[observability.traces]
enabled = true
# Must match the destination name in the dashboard
destinations = [ "sentry-traces" ]

[observability.logs]
enabled = true
# Must match the destination name in the dashboard
destinations = [ "sentry-logs" ]

After updating your configuration, deploy your Worker for the changes to take effect.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").