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
This guide demonstrates how to configure OpenTelemetry in Cloudflare Workers to send telemetry data to Axiom using the [OTel CF Worker package](https://github.com/evanderkoogh/otel-cf-workers).
Configure **`wrangler.toml`** with your Cloudflare account details and set environment variables for the Axiom API token and dataset.
@@ -85,10 +91,14 @@ main = "index.ts"
85
91
86
92
# Define environment variables here
87
93
[vars]
88
-
AXIOM_API_TOKEN="API_TOKEN" # Replace API_TOKENwith your actual Axiom API token
89
-
AXIOM_DATASET="DATASET_NAME" # Replace DATASET_NAMEwith your actual Axiom dataset name
94
+
AXIOM_API_TOKEN="API_TOKEN"
95
+
AXIOM_DATASET="DATASET_NAME"
90
96
```
91
97
98
+
<Info>
99
+
<ReplaceDatasetToken />
100
+
</Info>
101
+
92
102
## Install Dependencies
93
103
94
104
Navigate to the root directory of your project and add `@microlabs/otel-cf-workers` and other OTel packages to the `package.json` file.
@@ -249,26 +259,30 @@ Automatic instrumentation uses the **`@microlabs/otel-cf-workers`** package to a
249
259
250
260
Wrap your Cloudflare Workers script with the `instrument` function from the **`@microlabs/otel-cf-workers`** package. This automatically instruments incoming requests and outbound fetch calls.
2. Configuration: Provide configuration details, including how to export telemetry data and service metadata to Axiom as part of the `instrument` function call.
259
269
260
-
```js
261
-
constconfig= (env) => ({
262
-
exporter: {
263
-
url:'https://api.axiom.co/v1/traces',
264
-
headers: {
265
-
'Authorization':`Bearer ${env.AXIOM_API_TOKEN}`,
266
-
'X-Axiom-Dataset':`${env.AXIOM_DATASET}`
267
-
},
268
-
},
269
-
service: { name:'axiom-cloudflare-workers' },
270
-
});
271
-
```
270
+
```js
271
+
constconfig= (env) => ({
272
+
exporter: {
273
+
url:'https://AXIOM_DOMAIN/v1/traces',
274
+
headers: {
275
+
'Authorization':`Bearer ${env.AXIOM_API_TOKEN}`,
276
+
'X-Axiom-Dataset':`${env.AXIOM_DATASET}`
277
+
},
278
+
},
279
+
service: { name:'axiom-cloudflare-workers' },
280
+
});
281
+
```
282
+
283
+
<Info>
284
+
<ReplaceDomain />
285
+
</Info>
272
286
273
287
After instrumenting your Worker script, the `@microlabs/otel-cf-workers` package takes care of tracing automatically.
In this step, modify the Django views to use the tracer defined in `exporter.py`. By wrapping the view logic within `tracer.start_as_current_span`, you create spans that capture the execution of these views. This provides detailed insights into the performance of individual request handlers, helping to identify slow operations or errors.
@@ -203,33 +210,38 @@ Manual instrumentation in Python with OpenTelemetry involves adding code to crea
203
210
204
211
1. Install necessary OpenTelemetry packages to enable manual tracing capabilities in your Django app.
OpenTelemetry provides a [unified approach to collecting telemetry data](https://opentelemetry.io/docs/languages/net/) from your .NET applications. This guide explains how to configure OpenTelemetry in a .NET application to send telemetry data to Axiom using the OpenTelemetry SDK.
@@ -162,9 +164,9 @@ public static class TracingConfiguration
162
164
.AddHttpClientInstrumentation() // Add automatic instrumentation for HttpClient requests
163
165
.AddOtlpExporter(options=>// Configure the OTLP exporter
164
166
{
165
-
options.Endpoint=newUri("https://api.axiom.co/v1/traces"); // Set the endpoint for the exporter
167
+
options.Endpoint=newUri("https://AXIOM_DOMAIN/v1/traces"); // Set the endpoint for the exporter
166
168
options.Protocol=OpenTelemetry.Exporter.OtlpExportProtocol.HttpProtobuf; // Set the protocol
167
-
options.Headers="Authorization=Bearer API_TOKEN, X-Axiom-Dataset=DATASET"; // Update API token and dataset
169
+
options.Headers="Authorization=Bearer API_TOKEN, X-Axiom-Dataset=DATASET_NAME"; // Update API token and dataset
168
170
})
169
171
.Build(); // Build the tracer provider
170
172
}
@@ -178,11 +180,11 @@ public static class TracingConfiguration
178
180
}
179
181
```
180
182
181
-
In the `tracing.cs` file, make the following changes:
182
-
183
-
- Replace the value of the `serviceName` variable with the name of the service you want to trace. This is used for identifying and categorizing trace data, particularly in systems with multiple services.
184
-
- Replace `API_TOKEN` with your Axiom API key.
185
-
- Replace `DATASET_NAME` with the name of the Axiom dataset where you want to send data.
183
+
<Info>
184
+
Replace the value of the `serviceName` variable with the name of the service you want to trace. This is used for identifying and categorizing trace data, particularly in systems with multiple services.
185
+
<ReplaceDatasetToken />
186
+
<ReplaceDomain />
187
+
</Info>
186
188
187
189
## Run the instrumented application
188
190
@@ -247,18 +249,22 @@ Automatic instrumentation uses the OpenTelemetry SDK and additional libraries to
247
249
248
250
1. Configure OpenTelemetry SDK. Use the OpenTelemetry SDK to configure automatic instrumentation in your application. This typically involves setting up a `TracerProvider` in your `program.cs` or startup configuration, which automatically captures telemetry data from supported libraries.
2. Install and configure additional OpenTelemetry instrumentation packages as needed, based on the technologies your application uses. For example, to automatically trace SQL database queries, you might add the corresponding database instrumentation package.
OpenTelemetry offers a [single set of APIs and libraries](https://opentelemetry.io/docs/languages/go/instrumentation/) that standardize how you collect and transfer telemetry data. This guide focuses on setting up OpenTelemetry in a Go app to send traces to Axiom.
13
14
@@ -223,7 +224,7 @@ import (
223
224
const (
224
225
serviceName = "axiom-go-otel"// Name of the service for tracing.
225
226
serviceVersion = "0.1.0"// Version of the service.
0 commit comments