# OpenTelemetry Support | Sentry for Koa

In `8.x`, the Tracing APIs for the SDK been completely overhauled. It is now powered by [OpenTelemetry](https://opentelemetry.io/.md) under the hood.

You do not need to know or understand what OpenTelemetry is in order to use Sentry. We set up OpenTelemetry under the hood.

If you want, you can use OpenTelemetry-native APIs to start spans, and Sentry will pick up everything automatically.

### [Accessing the OpenTelemetry Tracer](https://docs.sentry.io/.md#accessing-the-opentelemetry-tracer)

You can access the tracer instance to add custom spans or context to your traces. This means you can rely on OpenTelemetry APIs to start spans, and Sentry will pick up everything automatically.

```JavaScript
const tracer = Sentry.getClient().tracer;

const span1 = tracer.startSpan('work-1');
// Do some work
span1.end();
```

We recommend using the [performance monitoring APIs](https://docs.sentry.io/v8-new-performance-api.md) provided by Sentry, as they are more user-friendly and provide additional features.

### [Custom OpenTelemetry Instrumentation](https://docs.sentry.io/.md#custom-opentelemetry-instrumentation)

While we include some vetted OpenTelemetry instrumentation out of the box, you can also add your own instrumentation on top of that. You can do that by installing an instrumentation package and calling the `addOpenTelemetryInstrumentation` method:

```JavaScript
const { GenericPoolInstrumentation } = require('@opentelemetry/instrumentation-generic-pool');

Sentry.init({
  dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
});

// Afterwards, you can add additional instrumentation:
Sentry.addOpenTelemetryInstrumentation(new GenericPoolInstrumentation());
```

### [Custom OpenTelemetry Setup](https://docs.sentry.io/.md#custom-opentelemetry-setup)

The SDK also offers the ability to completely customize your OpenTelemetry setup.

In this case, you need to set `skipOpenTelemetrySetup: true` in your `Sentry.init` config, and ensure you setup all the components that Sentry needs yourself.

1. First, install the `@sentry/opentelemetry` package.

```bash
npm install @sentry/opentelemetry --save
```

2. Then add the `SentrySpanProcessor`, `SentryPropagator`, `SentryContextManager`, and `SentrySampler` to your OpenTelemetry SDK initialization.

```JavaScript
// Make sure Sentry is initialized before OpenTelemetry
Sentry.init({
  dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
  // Make sure to set this to disable the automatic OpenTelemetry setup
  skipOpenTelemetrySetup: true,
});

const { SentrySpanProcessor, SentryPropagator, SentryContextManager, SentrySampler } = require('@sentry/opentelemetry');

// We need to add a span processor to send spans to Sentry
provider.addSpanProcessor(new SentrySpanProcessor());

// We need a custom propagator and context manager
// This enables distributed tracing and context isolation
provier.register({
  propagator: new SentryPropagator(),
  contextManager: new SentryContextManager(),
});

// Optionally, if you want to use the `tracesSamplingRate` or sampling related options from Sentry,
// you also need to use a custom sampler when you set up your provider
const provider = new BasicTracerProvider({
  sampler: new SentrySampler(Sentry.getClient()),
});
```
