Skip to content

Commit 693f809

Browse files
authored
feat: Add example collector config to otlp docs + extra cleanup (#15128)
1. re-organize sections in otlp docs 2. add example collector config for both traces and logs 3. add android and flutter sdks to traceparent section (as per https://linear.app/getsentry/project/implement-traceparent-support-in-client-sdks-d842ae07e7d4/updates) 4. removes backend js platforms from traceparent section
1 parent d761769 commit 693f809

File tree

2 files changed

+70
-94
lines changed

2 files changed

+70
-94
lines changed

docs/concepts/otlp/index.mdx

Lines changed: 66 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,39 @@ If you have an existing OpenTelemetry trace instrumentation, you can configure y
1717
- Span links are partially supported. We ingest and display span links, but they cannot be searched, filtered, or aggregated. Links are shown in the [Trace View](/concepts/key-terms/tracing/trace-view/).
1818
- Array attributes are partially supported. We ingest and display array attributes, but they cannot be searched, filtered, or aggregated. Array attributes are shown in the [Trace View](/concepts/key-terms/tracing/trace-view/).
1919

20+
You can find the values of Sentry's OTLP traces endpoint and public key in your Sentry project settings.
21+
22+
1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
23+
2. Select a project from the list.
24+
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.
25+
2026
The easiest way to configure an OpenTelemetry exporter is with environment variables. You'll need to configure the trace endpoint URL, as well as the authentication headers. Set these variables on the server where your application is running.
2127

2228
```bash {filename: .env}
2329
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="___OTLP_TRACES_URL___"
2430
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-sentry-auth=sentry sentry_key=___PUBLIC_KEY___"
2531
```
2632

27-
Alternatively, you can configure the OpenTelemetry Exporter directly in your application code. Here is an example with the OpenTelemetry Node SDK:
33+
If you prefer to explicitly configure an OpenTelemetry SDK or OTEL collector instance, see the following:
34+
35+
### Using the OTEL Collector
36+
37+
You can configure your OTEL collector instance to send traces to Sentry directly. This requires you to add an `otlphttp` exporter to your collector instance. Sentry's OTLP endpoints are project-specific, so you might also need to add a [routing connector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector) to route traces to the correct project.
38+
39+
```yaml {filename: otel-collector.yaml}
40+
exporters:
41+
otlphttp:
42+
traces_endpoint: ___OTLP_TRACES_URL___
43+
headers:
44+
x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
45+
compression: gzip
46+
encoding: proto
47+
timeout: 30s
48+
```
49+
50+
### Using an OpenTelemetry SDK
51+
52+
You can configure the OpenTelemetry Exporter directly in your application code. Here is an example with the OpenTelemetry Node SDK:
2853
2954
```typescript {filename: app.ts}
3055
import { NodeSDK } from "@opentelemetry/sdk-node";
@@ -42,12 +67,6 @@ const sdk = new NodeSDK({
4267
sdk.start();
4368
```
4469

45-
You can find the values of Sentry's OTLP traces endpoint and public key in your Sentry project settings.
46-
47-
1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
48-
2. Select a project from the list.
49-
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.
50-
5170
## OpenTelemetry Logs
5271

5372
<Include name="feature-available-ea-logs.mdx" />
@@ -56,13 +75,38 @@ If you have an existing OpenTelemetry log instrumentation, you can configure you
5675

5776
- Array attributes are partially supported. We ingest and display array attributes, but they cannot be searched, filtered, or aggregated.
5877

59-
The easiest way to configure an OpenTelemetry exporter is with environment variables. You'll need to configure the trace endpoint URL, as well as the authentication headers. Set these variables on the server where your application is running.
78+
You can find the values of Sentry's OTLP logs endpoint and public key in your Sentry project settings.
79+
80+
1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
81+
2. Select a project from the list.
82+
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.
83+
84+
The easiest way to configure an OpenTelemetry exporter is with environment variables. You'll need to configure the logs endpoint URL, as well as the authentication headers. Set these variables on the server where your application is running.
6085

6186
```bash {filename: .env}
6287
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="___OTLP_LOGS_URL___"
6388
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="x-sentry-auth=sentry sentry_key=___PUBLIC_KEY___"
6489
```
6590

91+
If you prefer to explicitly configure an OpenTelemetry SDK or OTEL collector instance, see the following:
92+
93+
### Using the OTEL Collector
94+
95+
You can configure your OTEL collector instance to send logs to Sentry directly. This requires you to add an `otlphttp` exporter to your collector instance. Sentry's OTLP endpoints are project-specific, so you might also need to add a [routing connector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector) to route logs to the correct project.
96+
97+
```yaml {filename: otel-collector.yaml}
98+
exporters:
99+
otlphttp:
100+
logs_endpoint: ___OTLP_LOGS_URL___
101+
headers:
102+
x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___"
103+
compression: gzip
104+
encoding: proto
105+
timeout: 30s
106+
```
107+
108+
### Using an OpenTelemetry SDK
109+
66110
Alternatively, you can configure the OpenTelemetry Exporter directly in your application code. Here is an example with the OpenTelemetry Node SDK:
67111
68112
```typescript {filename: app.ts}
@@ -85,12 +129,6 @@ const loggerProvider = new LoggerProvider({
85129
const logger = loggerProvider.getLogger("default", "1.0.0");
86130
```
87131

88-
You can find the values of Sentry's OTLP logs endpoint and public key in your Sentry project settings.
89-
90-
1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
91-
2. Select a project from the list.
92-
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.
93-
94132
## Distributed Tracing between Sentry Instrumentation and OpenTelemetry Instrumentation
95133

96134
If you have a frontend or services instrumented with the Sentry SDK, and you are also instrumenting with OpenTelemetry, you can use the `propagateTraceparent` exposed in the Sentry SDK to propagate the W3C Trace Context `traceparent` header to the OpenTelemetry instrumentation. This will allow you to continue traces from Sentry instrumented services.
@@ -102,7 +140,7 @@ The following SDKs support the `propagateTraceparent` option:
102140
- <LinkWithPlatformIcon
103141
platform="javascript.browser"
104142
label="Browser JavaScript"
105-
url="platforms/javascript/configuration/options/#propagateTraceparent"
143+
url="/platforms/javascript/configuration/options/#propagateTraceparent"
106144
/>
107145
- <LinkWithPlatformIcon
108146
platform="javascript.angular"
@@ -114,86 +152,16 @@ The following SDKs support the `propagateTraceparent` option:
114152
label="Astro"
115153
url="/platforms/javascript/guides/astro/configuration/options/#propagateTraceparent"
116154
/>
117-
- <LinkWithPlatformIcon
118-
platform="javascript.aws-lambda"
119-
label="AWS Lambda"
120-
url="/platforms/javascript/guides/aws-lambda/configuration/options/#propagateTraceparent"
121-
/>
122-
- <LinkWithPlatformIcon
123-
platform="javascript.azure-functions"
124-
label="Azure Functions"
125-
url="/platforms/javascript/guides/azure-functions/configuration/options/#propagateTraceparent"
126-
/>
127-
- <LinkWithPlatformIcon
128-
platform="javascript.bun"
129-
label="Bun"
130-
url="/platforms/javascript/guides/bun/configuration/options/#propagateTraceparent"
131-
/>
132-
- <LinkWithPlatformIcon
133-
platform="javascript.cloudflare"
134-
label="Cloudflare"
135-
url="/platforms/javascript/guides/cloudflare/configuration/options/#propagateTraceparent"
136-
/>
137-
- <LinkWithPlatformIcon
138-
platform="javascript.connect"
139-
label="Connect"
140-
url="/platforms/javascript/guides/connect/configuration/options/#propagateTraceparent"
141-
/>
142-
- <LinkWithPlatformIcon
143-
platform="javascript.electron"
144-
label="Electron"
145-
url="/platforms/javascript/guides/electron/configuration/options/#propagateTraceparent"
146-
/>
147155
- <LinkWithPlatformIcon
148156
platform="javascript.ember"
149157
label="Ember"
150158
url="/platforms/javascript/guides/ember/configuration/options/#propagateTraceparent"
151159
/>
152-
- <LinkWithPlatformIcon
153-
platform="javascript.express"
154-
label="Express"
155-
url="/platforms/javascript/guides/express/configuration/options/#propagateTraceparent"
156-
/>
157-
- <LinkWithPlatformIcon
158-
platform="javascript.fastify"
159-
label="Fastify"
160-
url="/platforms/javascript/guides/fastify/configuration/options/#propagateTraceparent"
161-
/>
162160
- <LinkWithPlatformIcon
163161
platform="javascript.gatsby"
164162
label="Gatsby"
165163
url="/platforms/javascript/guides/gatsby/configuration/options/#propagateTraceparent"
166164
/>
167-
- <LinkWithPlatformIcon
168-
platform="javascript.gcp-functions"
169-
label="Google Cloud Functions"
170-
url="/platforms/javascript/guides/gcp-functions/configuration/options/#propagateTraceparent"
171-
/>
172-
- <LinkWithPlatformIcon
173-
platform="javascript.hapi"
174-
label="Hapi"
175-
url="/platforms/javascript/guides/hapi/configuration/options/#propagateTraceparent"
176-
/>
177-
- <LinkWithPlatformIcon
178-
platform="javascript.hono"
179-
label="Hono"
180-
url="/platforms/javascript/guides/hono/configuration/options/#propagateTraceparent"
181-
/>
182-
- <LinkWithPlatformIcon
183-
platform="javascript.koa"
184-
label="Koa"
185-
url="/platforms/javascript/guides/koa/configuration/options/#propagateTraceparent"
186-
/>
187-
- <LinkWithPlatformIcon
188-
platform="javascript.nestjs"
189-
label="Nest.js"
190-
url="/platforms/javascript/guides/nestjs/configuration/options/#propagateTraceparent"
191-
/>
192-
- <LinkWithPlatformIcon
193-
platform="javascript.node"
194-
label="Node.js"
195-
url="/platforms/javascript/guides/node/configuration/options/#propagateTraceparent"
196-
/>
197165
- <LinkWithPlatformIcon
198166
platform="javascript.nextjs"
199167
label="Next.js"
@@ -239,11 +207,6 @@ The following SDKs support the `propagateTraceparent` option:
239207
label="SvelteKit"
240208
url="/platforms/javascript/guides/sveltekit/configuration/options/#propagateTraceparent"
241209
/>
242-
- <LinkWithPlatformIcon
243-
platform="javascript.tanstackstart-react"
244-
label="TanStack Start"
245-
url="/platforms/javascript/guides/tanstackstart-react/configuration/options/#propagateTraceparent"
246-
/>
247210
- <LinkWithPlatformIcon
248211
platform="javascript.vue"
249212
label="Vue"
@@ -254,3 +217,16 @@ The following SDKs support the `propagateTraceparent` option:
254217
label="Wasm"
255218
url="/platforms/javascript/guides/wasm/configuration/options/#propagateTraceparent"
256219
/>
220+
221+
### Mobile
222+
223+
- <LinkWithPlatformIcon
224+
platform="android"
225+
label="Android"
226+
url="/platforms/android/configuration/options/#propagate-traceparent"
227+
/>
228+
- <LinkWithPlatformIcon
229+
platform="dart.flutter"
230+
label="Flutter"
231+
url="/platforms/dart/guides/flutter/configuration/options/#propagate-traceparent"
232+
/>

src/components/codeContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ export const DEFAULTS: CodeKeywords = {
8888
MINIDUMP_URL:
8989
'https://o0.ingest.sentry.io/api/0/minidump/?sentry_key=examplePublicKey',
9090
UNREAL_URL: 'https://o0.ingest.sentry.io/api/0/unreal/examplePublicKey/',
91-
OTLP_TRACES_URL: 'https://o0.ingest.sentry.io/api/0/integration/otlp/v1/traces/',
92-
OTLP_LOGS_URL: 'https://o0.ingest.sentry.io/api/0/integration/otlp/v1/logs/',
91+
OTLP_TRACES_URL: 'https://o0.ingest.sentry.io/api/0/integration/otlp/v1/traces',
92+
OTLP_LOGS_URL: 'https://o0.ingest.sentry.io/api/0/integration/otlp/v1/logs',
9393
title: `example-org / example-project`,
9494
},
9595
],
@@ -142,11 +142,11 @@ const formatUnrealEngineURL = ({scheme, host, pathname, publicKey}: Dsn) => {
142142
};
143143

144144
const formatOtlpTracesUrl = ({scheme, host, pathname}: Dsn) => {
145-
return `${scheme}${host}/api${pathname}/integration/otlp/v1/traces/`;
145+
return `${scheme}${host}/api${pathname}/integration/otlp/v1/traces`;
146146
};
147147

148148
const formatOtlpLogsUrl = ({scheme, host, pathname}: Dsn) => {
149-
return `${scheme}${host}/api${pathname}/integration/otlp/v1/logs/`;
149+
return `${scheme}${host}/api${pathname}/integration/otlp/v1/logs`;
150150
};
151151

152152
const formatApiUrl = ({scheme, host}: Dsn) => {

0 commit comments

Comments
 (0)