You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Metrics** - Performance metrics and custom measurements (**not yet supported**)
19
19
20
20
### Supported destinations
21
-
22
-
Cloudflare Workers can export data to any platform that supports the OpenTelemetry Protocol (OTLP), including:
23
-
- Datadog
24
-
- Honeycomb
25
-
- Grafana Cloud
26
-
- Sentry
27
-
- Custom OTLP endpoints
21
+
Cloudflare Workers can export data to any platform that supports proper OpenTelemetry Protocol (OTLP) endpoints (e.g. `https://api.honeycomb.io/v1/traces`)
28
22
29
23
## Setting up OpenTelemetry-compatible destinations
30
24
@@ -37,7 +31,7 @@ Before you can export telemetry data, you need to create and configure a destina
37
31
-**Destination Name** - A descriptive name (e.g., "Datadog APM", "Honeycomb Logs")
38
32
-**Destination Type** - Choose between "Traces" or "Logs"
39
33
-**OTLP Endpoint** - The URL where your observability platform accepts OTLP data. This endpoint should end in `/logs` or /traces`
40
-
-**Custom Headers** (Optional) - Add any authentication headers or other required headers
34
+
-**Custom Headers** (Optional) - Any authentication headers or other required headers
41
35
42
36
## Enabling OpenTelemetry export for your Worker
43
37
@@ -60,10 +54,4 @@ After setting up destinations in the dashboard, configure your Worker to export
60
54
}
61
55
}
62
56
```
63
-
Then redeploy your Worker for new configurations to take effect.
64
-
65
-
### Configuration options
66
-
-**`enabled`** - Enable or disable telemetry collection
67
-
-**`head_sample_rate`** - Percentage of requests to sample (0.0 to 1.0)
68
-
-**`destinations`** - Array of destination names to export data to. These should be from the destination names created in the dashboard. Include `"cloudflare"` in this array to also send traces and logs to the Workers Dashboard.
69
-
57
+
Then redeploy your Worker for new configurations to take effect. It may take a few minutes for events to reach your destination.
Tracing gives you end-to-end visibility into the life of a request as it travels through your Workers application and connected services, helping you to identify performance bottlenecks, debug issues, and understand complex request flows.
13
13
14
14
With tracing you can answer questions such as:
15
15
* What is the cause of a long-running request?
16
-
* Where in the chain of services did a request fail?
17
16
* How long do subrequests to my Worker take?
18
17
* How long are my requests to my KV Namespace or R2 bucket taking?
19
18
20
19
## Automatic instrumentation
21
20
22
21
Each trace consists of one or more spans, representing the various calls made to different Worker services as part of the invocation. Cloudflare has automatically instrumented fetch calls and requests to Cloudflare resources (e.g. Workers KV, D1 Databases, Durable Objects) bound to your Workers application, without requiring you to install and configure an OpenTelemetry SDK.
23
22
24
-
Take for example, application that handles online ordering and makes request to a D1 Database to fetch customer information, an external API to validate payment information, and a Cloudflare Queue to submit the order.
23
+
Take for example, an application that handles online ordering and makes request to a D1 Database to fetch customer information, an external API to validate payment information, and a Cloudflare Queue to submit the order. Tracing lets you visualize an invocation call by call at each part of the request journey. Our example above may look something like this:
25
24
26
-
Tracing lets you visualize an invocation call by call at each part of the request journey. Our example above may look something like this:
25
+
**TODO: insert example of trace here**
27
26
28
-
TODO: insert example of trace here
27
+
While our work for automatic instrumentation is ongoing, we've [documented](/workers/observability/traces/spans-and-attributes) all existing spans and attributes currently instrumented today.
29
28
30
29
## How to enable tracing
31
30
32
-
If you would like to view traces in the Cloudflare Dashboard using Workers Observability, you can set the following in your Wrangler configuration file:
31
+
To view traces in the Workers dashboard, you can set the following in your Wrangler configuration file:
33
32
34
33
```jsonc title="wrangler.jsonc"
35
34
36
-
{
37
-
"observability": {
38
-
// enabling traces
39
-
"traces": {
40
-
"enabled":true,
41
-
},
42
-
}
35
+
"observability": {
36
+
// enabling traces
37
+
"traces": {
38
+
"enabled":true
39
+
},
43
40
}
44
-
```
45
41
46
-
You can also export OpenTelemetry traces to a 3rd party destination such as Datadog or Honeycomb.
42
+
```
43
+
Or simply include the following to persist logs **and** traces to the Workers dashboard:
47
44
48
-
### Exporting OpenTelemetry traces to a 3rd party destination
45
+
```jsonc title="wrangler.jsonc"
49
46
50
-
In addition to viewing traces in the Cloudflare Dashboard, you can export traces to any OpenTelemetry-compatible destination, including popular platforms such as Datadog and Honeycomb.
47
+
"observability": {
48
+
"enabled":true
49
+
}
51
50
52
-
To configure trace export to external destinations, you'll need to set up a destination in the Cloudflare dashboard and set your desired destination within your Wrangler configuration.
51
+
```
53
52
53
+
### Exporting OpenTelemetry traces to a 3rd party destination
54
+
You can also export [OpenTelemetry](https://opentelemetry.io/) (OTel) traces to a 3rd party destination such as Honeycomb by [setting up an external destination](/src/content/docs/workers/observability/exporting-opentelemetry-data/index.mdx) in the Cloudflare dashboard and setting that destination in your Wrangler configuration file. Learn more [here](/src/content/docs/workers/observability/exporting-opentelemetry-data/index.mdx).
54
55
55
56
## Head-based sampling
57
+
Head-based sampling allows you to trace a percentage of incoming requests in your Cloudflare Worker. With sampling, you can help reduce volume and manage costs, while still providing meaningful insights into your application. You can configure head-based sampling for both tracing and logging separately on a per-Worker basis.
56
58
57
-
Head-based sampling allows you to trace a percentage of incoming requests in your Cloudflare Worker. Most production applications at scale use head sampling because it is unnecessary and costly to trace every single request. With sampling, you can help reduce volume and manage costs, while still providing meaningful insights into your application.
58
-
59
-
You can configure head-based sampling for both tracing and logging separately on a per-Worker basis. The valid range is from 0 to 1, where 0 indicates zero out of one hundred invocations will be traced, and 1 indicates every requests will be traced. If head_sampling_rate is unspecified, it defaults to tracing 100% of requests.
59
+
The valid range is from 0 to 1, where 0 indicates zero out of one hundred invocations will be traced, and 1 indicates every requests will be traced. If `head_sampling_rate` is unspecified, it defaults to tracing 100% of requests.
60
60
61
-
You can configure this in your Wrangler configuration like this:
61
+
You can configure `head_sampling_rate` in your Wrangler configuration. If you have logs enabled with a `head_sampling_rate`, you can create a separate `head_sampling_rate` for traces.
62
62
63
63
```jsonc title="wrangler.jsonc"
64
64
65
-
{
65
+
"observability":{
66
66
"tracing": {
67
67
68
68
"enabled":true
69
-
"destinations": ["datadog"]
70
69
// set tracing sampling rate to 5%
71
70
"head_sample_rate":0.05
72
71
},
@@ -85,16 +84,14 @@ Workers tracing is currently **free** during the early beta period. This include
85
84
86
85
Starting on xx/xx/xxxx, tracing will be billed as part of Workers observability. Each span in a trace counts as one observability event, sharing the same monthly quota and pricing as [Workers logs](https://developers.cloudflare.com/workers/platform/pricing/#workers-logs):
87
86
88
-
|| Events (trace spans or log events) | Retention |
87
+
|| Events (trace spans or log events) | Retention |
0 commit comments