Skip to content

Commit 7b83d92

Browse files
authored
feat(otlp): Add docs for OTLP logs endpoint (#14898)
resolves https://linear.app/getsentry/issue/LOGS-347/add-docs-for-otlp-logs-endpoint
1 parent 488ab66 commit 7b83d92

File tree

7 files changed

+231
-21
lines changed

7 files changed

+231
-21
lines changed

docs/concepts/otlp/index.mdx

Lines changed: 214 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ description: "Learn how to send OpenTelemetry trace data directly to Sentry from
55
keywords: ["otlp", "otel", "opentelemetry"]
66
---
77

8-
<Include name="feature-available-alpha-otlp.mdx" />
8+
Sentry can ingest [OpenTelemetry](https://opentelemetry.io) traces and logs directly via the [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/). Sentry does not support ingesting OTLP metrics.
99

10-
Sentry can ingest [OpenTelemetry](https://opentelemetry.io) traces directly via the [OpenTelemetry Protocol](https://opentelemetry.io/docs/specs/otel/protocol/). If you have an existing OpenTelemetry trace instrumentation, you can configure your OpenTelemetry exporter to send traces to Sentry directly. Sentry's OTLP ingestion endpoint is currently in development, and has a few known limitations:
10+
## OpenTelemetry Traces
11+
12+
<Include name="feature-available-alpha-tracing.mdx" />
13+
14+
If you have an existing OpenTelemetry trace instrumentation, you can configure your OpenTelemetry exporter to send traces to Sentry directly. Sentry's OTLP ingestion traces endpoint is currently in development, and has a few known limitations:
1115

1216
- Span events are not supported. All span events are dropped during ingestion.
1317
- Span links are partially supported. We ingest and display span links, but they cannot be searched, filtered, or aggregated. Links are are shown in the [Trace View](/concepts/key-terms/tracing/trace-view/).
1418
- 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/).
15-
- Sentry does not support ingesting OTLP metrics or OTLP logs.
1619

1720
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.
1821

@@ -39,8 +42,215 @@ const sdk = new NodeSDK({
3942
sdk.start();
4043
```
4144

42-
You can find the values of Sentry's OTLP endpoint and public key in your Sentry project settings.
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+
51+
## OpenTelemetry Logs
52+
53+
<Include name="feature-available-alpha-logs.mdx" />
54+
55+
If you have an existing OpenTelemetry log instrumentation, you can configure your OpenTelemetry exporter to send logs to Sentry directly. Sentry's OTLP ingestion logs endpoint has the following known limitations:
56+
57+
- Array attributes are partially supported. We ingest and display array attributes, but they cannot be searched, filtered, or aggregated.
58+
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.
60+
61+
```bash {filename: .env}
62+
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="___OTLP_LOGS_URL___"
63+
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="x-sentry-auth=sentry sentry_key=___PUBLIC_KEY___"
64+
```
65+
66+
Alternatively, you can configure the OpenTelemetry Exporter directly in your application code. Here is an example with the OpenTelemetry Node SDK:
67+
68+
```typescript {filename: app.ts}
69+
import {
70+
LoggerProvider,
71+
BatchLogRecordProcessor,
72+
} from "@opentelemetry/sdk-logs";
73+
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
74+
75+
const logExporter = new OTLPLogExporter({
76+
url: "___OTLP_LOGS_URL___",
77+
headers: {
78+
"x-sentry-auth": "sentry sentry_key=___PUBLIC_KEY___",
79+
},
80+
});
81+
const loggerProvider = new LoggerProvider({
82+
processors: [new BatchLogRecordProcessor(logExporter)],
83+
});
84+
85+
const logger = loggerProvider.getLogger("default", "1.0.0");
86+
```
87+
88+
You can find the values of Sentry's OTLP logs endpoint and public key in your Sentry project settings.
4389

4490
1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
4591
2. Select a project from the list.
4692
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.
93+
94+
## Distributed Tracing between Sentry Instrumentation and OpenTelemetry Instrumentation
95+
96+
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.
97+
98+
The following SDKs support the `propagateTraceparent` option:
99+
100+
### JavaScript
101+
102+
- <LinkWithPlatformIcon
103+
platform="javascript.browser"
104+
label="Browser JavaScript"
105+
url="platforms/javascript/configuration/options/#propagateTraceparent"
106+
/>
107+
- <LinkWithPlatformIcon
108+
platform="javascript.angular"
109+
label="Angular"
110+
url="/platforms/javascript/guides/angular/configuration/options/#propagateTraceparent"
111+
/>
112+
- <LinkWithPlatformIcon
113+
platform="javascript.astro"
114+
label="Astro"
115+
url="/platforms/javascript/guides/astro/configuration/options/#propagateTraceparent"
116+
/>
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+
/>
147+
- <LinkWithPlatformIcon
148+
platform="javascript.ember"
149+
label="Ember"
150+
url="/platforms/javascript/guides/ember/configuration/options/#propagateTraceparent"
151+
/>
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+
/>
162+
- <LinkWithPlatformIcon
163+
platform="javascript.gatsby"
164+
label="Gatsby"
165+
url="/platforms/javascript/guides/gatsby/configuration/options/#propagateTraceparent"
166+
/>
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+
/>
197+
- <LinkWithPlatformIcon
198+
platform="javascript.nextjs"
199+
label="Next.js"
200+
url="/platforms/javascript/guides/nextjs/configuration/options/#propagateTraceparent"
201+
/>
202+
- <LinkWithPlatformIcon
203+
platform="javascript.nuxt"
204+
label="Nuxt"
205+
url="/platforms/javascript/guides/nuxt/configuration/options/#propagateTraceparent"
206+
/>
207+
- <LinkWithPlatformIcon
208+
platform="javascript.react"
209+
label="React"
210+
url="/platforms/javascript/guides/react/configuration/options/#propagateTraceparent"
211+
/>
212+
- <LinkWithPlatformIcon
213+
platform="javascript.react-router"
214+
label="React Router"
215+
url="/platforms/javascript/guides/react-router/configuration/options/#propagateTraceparent"
216+
/>
217+
- <LinkWithPlatformIcon
218+
platform="javascript.remix"
219+
label="Remix"
220+
url="/platforms/javascript/guides/remix/configuration/options/#propagateTraceparent"
221+
/>
222+
- <LinkWithPlatformIcon
223+
platform="javascript.solid"
224+
label="Solid"
225+
url="/platforms/javascript/guides/solid/configuration/options/#propagateTraceparent"
226+
/>
227+
- <LinkWithPlatformIcon
228+
platform="javascript.solidstart"
229+
label="SolidStart"
230+
url="/platforms/javascript/guides/solidstart/configuration/options/#propagateTraceparent"
231+
/>
232+
- <LinkWithPlatformIcon
233+
platform="javascript.svelte"
234+
label="Svelte"
235+
url="/platforms/javascript/guides/svelte/configuration/options/#propagateTraceparent"
236+
/>
237+
- <LinkWithPlatformIcon
238+
platform="javascript.sveltekit"
239+
label="SvelteKit"
240+
url="/platforms/javascript/guides/sveltekit/configuration/options/#propagateTraceparent"
241+
/>
242+
- <LinkWithPlatformIcon
243+
platform="javascript.tanstackstart-react"
244+
label="TanStack Start"
245+
url="/platforms/javascript/guides/tanstackstart-react/configuration/options/#propagateTraceparent"
246+
/>
247+
- <LinkWithPlatformIcon
248+
platform="javascript.vue"
249+
label="Vue"
250+
url="/platforms/javascript/guides/vue/configuration/options/#propagateTraceparent"
251+
/>
252+
- <LinkWithPlatformIcon
253+
platform="javascript.wasm"
254+
label="Wasm"
255+
url="/platforms/javascript/guides/wasm/configuration/options/#propagateTraceparent"
256+
/>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Alert>
2+
3+
This feature is in alpha and is only available if your organization is participating in its limited release. Please reach out to [feedback-logging@sentry.io](mailto:feedback-logging@sentry.io) if you want access. Features in alpha are still in-progress and may have bugs. We recognize the irony.
4+
5+
</Alert>

includes/feature-available-alpha-otlp.mdx

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Alert>
2+
3+
This feature is in alpha and is only available if your organization is participating in its limited release. Please reach out to [feedback-tracing@sentry.io](mailto:feedback-tracing@sentry.io) if you want access. Features in alpha are still in-progress and may have bugs. We recognize the irony.
4+
5+
</Alert>

includes/feature-stage-alpha-metrics.mdx

Lines changed: 0 additions & 6 deletions
This file was deleted.

includes/feature-stage-beta-metrics.mdx

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/components/codeContext.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type ProjectCodeKeywords = {
1414
ORG_ID: number;
1515
ORG_INGEST_DOMAIN: string;
1616
ORG_SLUG: string;
17+
OTLP_LOGS_URL: string;
1718
OTLP_TRACES_URL: string;
1819
PROJECT_ID: number;
1920
PROJECT_SLUG: string;
@@ -88,6 +89,7 @@ export const DEFAULTS: CodeKeywords = {
8889
'https://o0.ingest.sentry.io/api/0/minidump/?sentry_key=examplePublicKey',
8990
UNREAL_URL: 'https://o0.ingest.sentry.io/api/0/unreal/examplePublicKey/',
9091
OTLP_TRACES_URL: 'https://o0.ingest.sentry.io/api/0/otlp/v1/traces/',
92+
OTLP_LOGS_URL: 'https://o0.ingest.sentry.io/api/0/integrations/otlp/v1/logs/',
9193
title: `example-org / example-project`,
9294
},
9395
],
@@ -143,6 +145,10 @@ const formatOtlpTracesUrl = ({scheme, host, pathname}: Dsn) => {
143145
return `${scheme}${host}/api${pathname}/otlp/v1/traces/`;
144146
};
145147

148+
const formatOtlpLogsUrl = ({scheme, host, pathname}: Dsn) => {
149+
return `${scheme}${host}/api${pathname}/integrations/otlp/v1/logs/`;
150+
};
151+
146152
const formatApiUrl = ({scheme, host}: Dsn) => {
147153
const apiHost = host.indexOf('.ingest.') >= 0 ? host.split('.ingest.')[1] : host;
148154

@@ -236,6 +242,7 @@ export async function fetchCodeKeywords(): Promise<CodeKeywords> {
236242
MINIDUMP_URL: formatMinidumpURL(parsedDsn),
237243
UNREAL_URL: formatUnrealEngineURL(parsedDsn),
238244
OTLP_TRACES_URL: formatOtlpTracesUrl(parsedDsn),
245+
OTLP_LOGS_URL: formatOtlpLogsUrl(parsedDsn),
239246
title: `${project.organizationSlug} / ${project.projectSlug}`,
240247
};
241248
}),

0 commit comments

Comments
 (0)