Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 214 additions & 4 deletions docs/concepts/otlp/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ description: "Learn how to send OpenTelemetry trace data directly to Sentry from
keywords: ["otlp", "otel", "opentelemetry"]
---

<Include name="feature-available-alpha-otlp.mdx" />
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.

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:
## OpenTelemetry Traces

<Include name="feature-available-alpha-tracing.mdx" />

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:

- Span events are not supported. All span events are dropped during ingestion.
- 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/).
- 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/).
- Sentry does not support ingesting OTLP metrics or OTLP logs.

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.

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

You can find the values of Sentry's OTLP endpoint and public key in your Sentry project settings.
You can find the values of Sentry's OTLP traces endpoint and public key in your Sentry project settings.

1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
2. Select a project from the list.
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.

## OpenTelemetry Logs

<Include name="feature-available-alpha-logs.mdx" />

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:

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect this list of limitations to grow? If not, I'd recommend not displaying this in a list format.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the list will grow, so I'll keep it like this for now.


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.

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

Alternatively, you can configure the OpenTelemetry Exporter directly in your application code. Here is an example with the OpenTelemetry Node SDK:

```typescript {filename: app.ts}
import {
LoggerProvider,
BatchLogRecordProcessor,
} from "@opentelemetry/sdk-logs";
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";

const logExporter = new OTLPLogExporter({
url: "___OTLP_LOGS_URL___",
headers: {
"x-sentry-auth": "sentry sentry_key=___PUBLIC_KEY___",
},
});
const loggerProvider = new LoggerProvider({
processors: [new BatchLogRecordProcessor(logExporter)],
});

const logger = loggerProvider.getLogger("default", "1.0.0");
```

You can find the values of Sentry's OTLP logs endpoint and public key in your Sentry project settings.

1. Go to the [Settings > Projects](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page in Sentry.
2. Select a project from the list.
3. Go to the "Client Keys (DSN)" sub-page for this project under the "SDK Setup" heading.

## Distributed Tracing between Sentry Instrumentation and OpenTelemetry Instrumentation

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.

The following SDKs support the `propagateTraceparent` option:

### JavaScript

- <LinkWithPlatformIcon
platform="javascript.browser"
label="Browser JavaScript"
url="platforms/javascript/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.angular"
label="Angular"
url="/platforms/javascript/guides/angular/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.astro"
label="Astro"
url="/platforms/javascript/guides/astro/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.aws-lambda"
label="AWS Lambda"
url="/platforms/javascript/guides/aws-lambda/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.azure-functions"
label="Azure Functions"
url="/platforms/javascript/guides/azure-functions/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.bun"
label="Bun"
url="/platforms/javascript/guides/bun/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.cloudflare"
label="Cloudflare"
url="/platforms/javascript/guides/cloudflare/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.connect"
label="Connect"
url="/platforms/javascript/guides/connect/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.electron"
label="Electron"
url="/platforms/javascript/guides/electron/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.ember"
label="Ember"
url="/platforms/javascript/guides/ember/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.express"
label="Express"
url="/platforms/javascript/guides/express/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.fastify"
label="Fastify"
url="/platforms/javascript/guides/fastify/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.gatsby"
label="Gatsby"
url="/platforms/javascript/guides/gatsby/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.gcp-functions"
label="Google Cloud Functions"
url="/platforms/javascript/guides/gcp-functions/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.hapi"
label="Hapi"
url="/platforms/javascript/guides/hapi/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.hono"
label="Hono"
url="/platforms/javascript/guides/hono/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.koa"
label="Koa"
url="/platforms/javascript/guides/koa/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.nestjs"
label="Nest.js"
url="/platforms/javascript/guides/nestjs/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.node"
label="Node.js"
url="/platforms/javascript/guides/node/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.nextjs"
label="Next.js"
url="/platforms/javascript/guides/nextjs/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.nuxt"
label="Nuxt"
url="/platforms/javascript/guides/nuxt/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.react"
label="React"
url="/platforms/javascript/guides/react/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.react-router"
label="React Router"
url="/platforms/javascript/guides/react-router/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.remix"
label="Remix"
url="/platforms/javascript/guides/remix/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.solid"
label="Solid"
url="/platforms/javascript/guides/solid/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.solidstart"
label="SolidStart"
url="/platforms/javascript/guides/solidstart/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.svelte"
label="Svelte"
url="/platforms/javascript/guides/svelte/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.sveltekit"
label="SvelteKit"
url="/platforms/javascript/guides/sveltekit/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.tanstackstart-react"
label="TanStack Start"
url="/platforms/javascript/guides/tanstackstart-react/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.vue"
label="Vue"
url="/platforms/javascript/guides/vue/configuration/options/#propagateTraceparent"
/>
- <LinkWithPlatformIcon
platform="javascript.wasm"
label="Wasm"
url="/platforms/javascript/guides/wasm/configuration/options/#propagateTraceparent"
/>
5 changes: 5 additions & 0 deletions includes/feature-available-alpha-logs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Alert>

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.

</Alert>
5 changes: 0 additions & 5 deletions includes/feature-available-alpha-otlp.mdx

This file was deleted.

5 changes: 5 additions & 0 deletions includes/feature-available-alpha-tracing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Alert>

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.

</Alert>
6 changes: 0 additions & 6 deletions includes/feature-stage-alpha-metrics.mdx

This file was deleted.

6 changes: 0 additions & 6 deletions includes/feature-stage-beta-metrics.mdx

This file was deleted.

7 changes: 7 additions & 0 deletions src/components/codeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ProjectCodeKeywords = {
ORG_ID: number;
ORG_INGEST_DOMAIN: string;
ORG_SLUG: string;
OTLP_LOGS_URL: string;
OTLP_TRACES_URL: string;
PROJECT_ID: number;
PROJECT_SLUG: string;
Expand Down Expand Up @@ -88,6 +89,7 @@ export const DEFAULTS: CodeKeywords = {
'https://o0.ingest.sentry.io/api/0/minidump/?sentry_key=examplePublicKey',
UNREAL_URL: 'https://o0.ingest.sentry.io/api/0/unreal/examplePublicKey/',
OTLP_TRACES_URL: 'https://o0.ingest.sentry.io/api/0/otlp/v1/traces/',
OTLP_LOGS_URL: 'https://o0.ingest.sentry.io/api/0/integrations/otlp/v1/logs/',
title: `example-org / example-project`,
},
],
Expand Down Expand Up @@ -143,6 +145,10 @@ const formatOtlpTracesUrl = ({scheme, host, pathname}: Dsn) => {
return `${scheme}${host}/api${pathname}/otlp/v1/traces/`;
};

const formatOtlpLogsUrl = ({scheme, host, pathname}: Dsn) => {
return `${scheme}${host}/api${pathname}/integrations/otlp/v1/logs/`;
};

const formatApiUrl = ({scheme, host}: Dsn) => {
const apiHost = host.indexOf('.ingest.') >= 0 ? host.split('.ingest.')[1] : host;

Expand Down Expand Up @@ -236,6 +242,7 @@ export async function fetchCodeKeywords(): Promise<CodeKeywords> {
MINIDUMP_URL: formatMinidumpURL(parsedDsn),
UNREAL_URL: formatUnrealEngineURL(parsedDsn),
OTLP_TRACES_URL: formatOtlpTracesUrl(parsedDsn),
OTLP_LOGS_URL: formatOtlpLogsUrl(parsedDsn),
title: `${project.organizationSlug} / ${project.projectSlug}`,
};
}),
Expand Down
Loading