Skip to content

Commit 084dc1b

Browse files
committed
feat(otlp): Add docs for OTLP logs endpoint
1 parent db4b24c commit 084dc1b

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

docs/concepts/otlp/index.mdx

Lines changed: 49 additions & 3 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+
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.
9+
10+
## OpenTelemetry Traces
11+
812
<Include name="feature-available-alpha-otlp.mdx" />
913

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:
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,7 +42,50 @@ 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-stage-beta.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 BatchRecordProcessor(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.

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/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}/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)