Capture Spans from OpenTelemetry APIs for SolidStart

Let Sentry capture and send spans created by OpenTelemetry APIs.

To capture spans that your code or a library creates through @opentelemetry/api, set enableOpenTelemetrySetup: true. Sentry registers an OpenTelemetry-compatible tracer provider, context manager, and propagator. Spans created through @opentelemetry/api become native Sentry spans. Sentry's tracing configuration controls sampling and export.

Copied
import * as Sentry from "___SDK_PACKAGE___";
import { trace } from "@opentelemetry/api";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
  enableOpenTelemetrySetup: true,
  tracesSampleRate: 1.0,
});

const tracer = trace.getTracer("my-app");

tracer.startActiveSpan("process-order", (span) => {
  try {
    // Your synchronous work here.
  } finally {
    span.end();
  }
});

Initialize Sentry before the application creates spans. This setup sends spans through Sentry's transport; it does not create an OTLP exporter. If your application already registers an OpenTelemetry provider, use your own OpenTelemetry pipeline instead. Sentry will not replace an existing provider.

Most server SDKs leave enableOpenTelemetrySetup off by default. The @sentry/nextjs and @sentry/sveltekit SDKs enable it by default to capture spans emitted by those frameworks.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").