Sentry
autotel-sentry sends Autotel traces to Sentry over OTLP. It parses a Sentry
DSN into the OTLP endpoint and auth headers that Autotel’s init() expects, and
installs a Sentry event processor that attaches the active OTel trace_id and
span_id to every error, so errors and traces line up in the Sentry UI.
[!NOTE] Earlier versions used a
SentrySpanProcessor/SentryPropagatorbridge built on deprecated Sentry Hub APIs. That bridge is removed. Sentry SDK v8+ ships its own OTel SDK, so Autotel owns OTel and exports straight to Sentry’s OTLP endpoint. No custom span processor.
Prerequisites
Section titled “Prerequisites”- Node.js 22+
@sentry/node>= 10.47.0 (exposesgetGlobalScope)autotelas a peer dependency
Installation
Section titled “Installation”npm install autotel autotel-sentry @sentry/nodeQuick start
Section titled “Quick start”import * as Sentry from '@sentry/node';import { init } from 'autotel';import { linkSentryErrors, sentryOtlpConfig } from 'autotel-sentry';
const config = sentryOtlpConfig(process.env.SENTRY_DSN!);
// 1. Initialize Sentry. Tell it not to register its own OTel SDK.Sentry.init({ dsn: config.dsn, skipOpenTelemetrySetup: true });
// 2. Initialize Autotel. It owns OTel and exports traces to Sentry's OTLP endpoint.init({ service: 'my-app', endpoint: config.endpoint, headers: config.headers });
// 3. Link Sentry errors to the active OTel trace.linkSentryErrors(Sentry);skipOpenTelemetrySetup: true is required. Sentry SDK v8+ registers its own OTel
SDK internally, and Autotel owns OTel setup. Without the flag you get duplicate
span processors and broken traces.
sentryOtlpConfig(dsn: string): SentryOtlpConfig
Section titled “sentryOtlpConfig(dsn: string): SentryOtlpConfig”Parses a Sentry DSN and returns the three values that wire Autotel to Sentry’s OTLP ingestion endpoint. Throws when the DSN is missing or cannot be parsed.
const config = sentryOtlpConfig('https://<key>@o<org>.ingest.sentry.io/<project>');// config.dsn normalized DSN string (pass to Sentry.init)// config.endpoint OTLP base URL (pass to Autotel init as `endpoint`)// config.headers auth headers (pass to Autotel init as `headers`)linkSentryErrors(sentry: SentryLinkable): void
Section titled “linkSentryErrors(sentry: SentryLinkable): void”Installs a global Sentry event processor that reads the active OTel span from
@opentelemetry/api and merges trace_id and span_id into every outgoing
Sentry event’s contexts.trace. Call it once, after both Sentry.init() and
init(). @sentry/node >= 10.47.0 satisfies the SentryLinkable interface.
Examples
Section titled “Examples”example-sentry: the Autotel + Sentry OTLP bridge with linked traces and errors.
See also
Section titled “See also”- Sentry OTLP docs for the Sentry-side configuration.
- Configuration for the
endpointandheadersoptions oninit().