Skip to content

Commit 2b99325

Browse files
authored
Provide better guidance on regions and domains (#272)
1 parent 3767b6b commit 2b99325

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+729
-343
lines changed

apps/hex.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ curl -X 'POST' 'https://AXIOM_DOMAIN/v1/datasets/DATASET_NAME/ingest' \
3838
]'
3939
```
4040

41+
<Info>
4142
<ReplaceDatasetToken />
4243
<ReplaceDomain />
44+
</Info>
4345

4446
Verify that your data has been ingested correctly by running an APL query in the Axiom UI.
4547

@@ -129,8 +131,10 @@ except Exception as e:
129131
print(f"\nError: {str(e)}")
130132
```
131133

134+
<Info>
132135
<ReplaceDomain />
133136
<ReplaceDataset />
137+
</Info>
134138

135139
## Create map visualisation
136140

guides/javascript.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ axiom.ingest('DATASET_NAME', [{ foo: 'bar' }]);
8181
await axiom.flush();
8282
```
8383

84+
<Info>
8485
<ReplaceDataset />
86+
</Info>
8587

8688
The client automatically batches events in the background. In most cases, call `flush()` only before your application exits.
8789

@@ -94,7 +96,9 @@ const res = await axiom.query(`['DATASET_NAME'] | where foo == 'bar' | limit 100
9496
console.log(res);
9597
```
9698

99+
<Info>
97100
<ReplaceDataset />
101+
</Info>
98102

99103
For more examples, see the [examples in GitHub](https://github.com/axiomhq/axiom-js/tree/main/examples).
100104

guides/opentelemetry-cloudflare-workers.mdx

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ tags: ['guides', 'cloudflare worker', 'otel', 'opentelemetry']
77
logoId: 'cloudflareWorkers'
88
---
99

10+
import ReplaceDomain from "/snippets/replace-domain.mdx"
1011
import Prerequisites from "/snippets/standard-prerequisites.mdx"
12+
import ReplaceDatasetToken from "/snippets/replace-dataset-token.mdx"
1113

1214
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).
1315

@@ -57,7 +59,7 @@ const handler = {
5759
const config: ResolveConfigFn = (env: Env, _trigger) => {
5860
return {
5961
exporter: {
60-
url: 'https://api.axiom.co/v1/traces',
62+
url: 'https://AXIOM_DOMAIN/v1/traces',
6163
headers: {
6264
'Authorization': `Bearer ${env.AXIOM_API_TOKEN}`,
6365
'X-Axiom-Dataset': `${env.AXIOM_DATASET}`
@@ -70,6 +72,10 @@ const config: ResolveConfigFn = (env: Env, _trigger) => {
7072
export default instrument(handler, config);
7173
```
7274
75+
<Info>
76+
<ReplaceDomain />
77+
</Info>
78+
7379
## Wrangler Configuration (`wrangler.toml`)
7480
7581
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"
8591

8692
# Define environment variables here
8793
[vars]
88-
AXIOM_API_TOKEN = "API_TOKEN" # Replace API_TOKEN with your actual Axiom API token
89-
AXIOM_DATASET = "DATASET_NAME" # Replace DATASET_NAME with your actual Axiom dataset name
94+
AXIOM_API_TOKEN = "API_TOKEN"
95+
AXIOM_DATASET = "DATASET_NAME"
9096
```
9197
98+
<Info>
99+
<ReplaceDatasetToken />
100+
</Info>
101+
92102
## Install Dependencies
93103
94104
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
249259
250260
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.
251261
252-
```js
253-
import { instrument } from '@microlabs/otel-cf-workers';
262+
```js
263+
import { instrument } from '@microlabs/otel-cf-workers';
254264

255-
export default instrument(yourHandler, yourConfig);
256-
```
265+
export default instrument(yourHandler, yourConfig);
266+
```
257267
258268
2. Configuration: Provide configuration details, including how to export telemetry data and service metadata to Axiom as part of the `instrument` function call.
259269
260-
```js
261-
const config = (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+
const config = (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>
272286
273287
After instrumenting your Worker script, the `@microlabs/otel-cf-workers` package takes care of tracing automatically.
274288

guides/opentelemetry-django.mdx

Lines changed: 65 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ logoId: 'openTelemetry'
88
---
99

1010
import Prerequisites from "/snippets/standard-prerequisites.mdx"
11+
import ReplaceDatasetToken from "/snippets/replace-dataset-token.mdx"
12+
import ReplaceDomain from "/snippets/replace-domain.mdx"
1113

1214
<Prerequisites />
1315
{/* list separator */}
@@ -115,7 +117,7 @@ provider = TracerProvider(resource=resource)
115117

116118
# Configure the OTLP/HTTP Span Exporter with necessary headers and endpoint
117119
otlp_exporter = OTLPSpanExporter(
118-
endpoint="https://api.axiom.co/v1/traces",
120+
endpoint="https://AXIOM_DOMAIN/v1/traces",
119121
headers={
120122
"Authorization": "Bearer API_TOKEN", # Replace with your actual API token
121123
"X-Axiom-Dataset": "DATASET_NAME" # Replace with your dataset name
@@ -133,6 +135,11 @@ trace.set_tracer_provider(provider)
133135
tracer = trace.get_tracer("your-service-name")
134136
```
135137

138+
<Info>
139+
<ReplaceDomain />
140+
<ReplaceDatasetToken />
141+
</Info>
142+
136143
### Use the tracer in your views
137144

138145
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
203210

204211
1. Install necessary OpenTelemetry packages to enable manual tracing capabilities in your Django app.
205212

206-
```py
207-
pip install django opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http opentelemetry-instrumentation-django
208-
```
213+
```py
214+
pip install django opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http opentelemetry-instrumentation-django
215+
```
209216

210217
2. Set up OpenTelemetry in your Django project to manually trace app activities.
211218

212-
```py
213-
# otel_config.py
214-
from opentelemetry import trace
215-
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
216-
from opentelemetry.sdk.resources import Resource
217-
from opentelemetry.sdk.trace import TracerProvider
218-
from opentelemetry.sdk.trace.export import BatchSpanProcessor
219-
220-
def configure_opentelemetry():
221-
resource = Resource(attributes={"service.name": "your-django-app"})
222-
trace.set_tracer_provider(TracerProvider(resource=resource))
223-
otlp_exporter = OTLPSpanExporter(
224-
endpoint="https://api.axiom.co/v1/traces",
225-
headers={"Authorization": "Bearer API_TOKEN", "X-Axiom-Dataset": "DATASET_NAME"}
226-
)
227-
span_processor = BatchSpanProcessor(otlp_exporter)
228-
trace.get_tracer_provider().add_span_processor(span_processor)
229-
return trace.get_tracer(__name__)
230-
231-
tracer = configure_opentelemetry()
232-
```
219+
```py
220+
# otel_config.py
221+
from opentelemetry import trace
222+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
223+
from opentelemetry.sdk.resources import Resource
224+
from opentelemetry.sdk.trace import TracerProvider
225+
from opentelemetry.sdk.trace.export import BatchSpanProcessor
226+
227+
def configure_opentelemetry():
228+
resource = Resource(attributes={"service.name": "your-django-app"})
229+
trace.set_tracer_provider(TracerProvider(resource=resource))
230+
otlp_exporter = OTLPSpanExporter(
231+
endpoint="https://AXIOM_DOMAIN/v1/traces",
232+
headers={"Authorization": "Bearer API_TOKEN", "X-Axiom-Dataset": "DATASET_NAME"}
233+
)
234+
span_processor = BatchSpanProcessor(otlp_exporter)
235+
trace.get_tracer_provider().add_span_processor(span_processor)
236+
return trace.get_tracer(__name__)
237+
238+
tracer = configure_opentelemetry()
239+
```
240+
241+
<Info>
242+
<ReplaceDomain />
243+
<ReplaceDatasetToken />
244+
</Info>
233245

234246
3. Configure OpenTelemetry to your Django settings to capture telemetry data upon app startup.
235247

@@ -288,32 +300,37 @@ Automatic instrumentation in Django with OpenTelemetry simplifies the process of
288300

289301
1. Install required packages that support automatic instrumentation.
290302

291-
```bash
292-
pip install django opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http opentelemetry-instrumentation-django
293-
```
303+
```bash
304+
pip install django opentelemetry-api opentelemetry-sdk opentelemetry-exporter-otlp-proto-http opentelemetry-instrumentation-django
305+
```
294306

295307
2. Automatically configure OpenTelemetry to trace Django app operations without manual span management.
296308

297-
```py
298-
# otel_config.py
299-
from opentelemetry import trace
300-
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
301-
from opentelemetry.instrumentation.django import DjangoInstrumentor
302-
from opentelemetry.sdk.resources import Resource
303-
from opentelemetry.sdk.trace import TracerProvider
304-
from opentelemetry.sdk.trace.export import BatchSpanProcessor
305-
306-
def configure_opentelemetry():
307-
resource = Resource(attributes={"service.name": "your-django-app"})
308-
trace.set_tracer_provider(TracerProvider(resource=resource))
309-
otlp_exporter = OTLPSpanExporter(
310-
endpoint="https://api.axiom.co/v1/traces",
311-
headers={"Authorization": "Bearer API_TOKEN", "X-Axiom-Dataset": "DATASET_NAME"}
312-
)
313-
span_processor = BatchSpanProcessor(otlp_exporter)
314-
trace.get_tracer_provider().add_span_processor(span_processor)
315-
DjangoInstrumentor().instrument()
316-
```
309+
```py
310+
# otel_config.py
311+
from opentelemetry import trace
312+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
313+
from opentelemetry.instrumentation.django import DjangoInstrumentor
314+
from opentelemetry.sdk.resources import Resource
315+
from opentelemetry.sdk.trace import TracerProvider
316+
from opentelemetry.sdk.trace.export import BatchSpanProcessor
317+
318+
def configure_opentelemetry():
319+
resource = Resource(attributes={"service.name": "your-django-app"})
320+
trace.set_tracer_provider(TracerProvider(resource=resource))
321+
otlp_exporter = OTLPSpanExporter(
322+
endpoint="https://AXIOM_DOMAIN/v1/traces",
323+
headers={"Authorization": "Bearer API_TOKEN", "X-Axiom-Dataset": "DATASET_NAME"}
324+
)
325+
span_processor = BatchSpanProcessor(otlp_exporter)
326+
trace.get_tracer_provider().add_span_processor(span_processor)
327+
DjangoInstrumentor().instrument()
328+
```
329+
330+
<Info>
331+
<ReplaceDomain />
332+
<ReplaceDatasetToken />
333+
</Info>
317334

318335
3. Initialize OpenTelemetry in Django to capture telemetry data from all HTTP requests automatically.
319336

guides/opentelemetry-dotnet.mdx

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ tags: ['guides', '.NET', 'dotnet', 'OpenTelemetry', 'otel']
77
logoId: 'openTelemetry'
88
---
99

10+
import ReplaceDatasetToken from "/snippets/replace-dataset-token.mdx"
11+
import ReplaceDomain from "/snippets/replace-domain.mdx"
1012
import Prerequisites from "/snippets/standard-prerequisites.mdx"
1113

1214
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
162164
.AddHttpClientInstrumentation() // Add automatic instrumentation for HttpClient requests
163165
.AddOtlpExporter(options => // Configure the OTLP exporter
164166
{
165-
options.Endpoint = new Uri("https://api.axiom.co/v1/traces"); // Set the endpoint for the exporter
167+
options.Endpoint = new Uri("https://AXIOM_DOMAIN/v1/traces"); // Set the endpoint for the exporter
166168
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
168170
})
169171
.Build(); // Build the tracer provider
170172
}
@@ -178,11 +180,11 @@ public static class TracingConfiguration
178180
}
179181
```
180182

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>
186188

187189
## Run the instrumented application
188190

@@ -247,18 +249,22 @@ Automatic instrumentation uses the OpenTelemetry SDK and additional libraries to
247249

248250
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.
249251

250-
```csharp
251-
Sdk.CreateTracerProviderBuilder()
252-
.AddAspNetCoreInstrumentation()
253-
.AddHttpClientInstrumentation()
254-
.AddOtlpExporter(options =>
255-
{
256-
options.Endpoint = new Uri("https://api.axiom.co/v1/traces");
257-
// Replace API_TOKEN and DATASET_NAME with your actual API token and dataset name
258-
options.Headers = $"Authorization=Bearer API_TOKEN, X-Axiom-Dataset=DATASET_NAME";
259-
})
260-
.Build();
261-
```
252+
```csharp
253+
Sdk.CreateTracerProviderBuilder()
254+
.AddAspNetCoreInstrumentation()
255+
.AddHttpClientInstrumentation()
256+
.AddOtlpExporter(options =>
257+
{
258+
options.Endpoint = new Uri("https://AXIOM_DOMAIN/v1/traces");
259+
options.Headers = $"Authorization=Bearer API_TOKEN, X-Axiom-Dataset=DATASET_NAME";
260+
})
261+
.Build();
262+
```
263+
264+
<Info>
265+
<ReplaceDatasetToken />
266+
<ReplaceDomain />
267+
</Info>
262268

263269
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.
264270

guides/opentelemetry-go.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ logoId: 'openTelemetry'
88
---
99

1010
import ReplaceDatasetToken from "/snippets/replace-dataset-token.mdx"
11+
import ReplaceDomain from "/snippets/replace-domain.mdx"
1112

1213
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.
1314

@@ -223,7 +224,7 @@ import (
223224
const (
224225
serviceName = "axiom-go-otel" // Name of the service for tracing.
225226
serviceVersion = "0.1.0" // Version of the service.
226-
otlpEndpoint = "api.axiom.co" // OTLP collector endpoint.
227+
otlpEndpoint = "AXIOM_DOMAIN" // OTLP collector endpoint.
227228
bearerToken = "Bearer API_TOKEN" // Authorization token.
228229
deploymentEnvironment = "production" // Deployment environment.
229230
)
@@ -274,7 +275,10 @@ func InstallExportPipeline(ctx context.Context) (func(context.Context) error, er
274275
}
275276
```
276277

278+
<Info>
277279
<ReplaceDatasetToken />
280+
<ReplaceDomain />
281+
</Info>
278282

279283
## Run the app
280284

0 commit comments

Comments
 (0)