# OpenTelemetry bridge

> Use @sypnia/telemetry/otel when your Node or Next.js app already uses OpenTelemetry, or when you want its instrumentations for more libraries; install, setup, what it adds, what it costs and how it lives beside @sypnia/telemetry/node.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://telemetry.docs.sypnia.com/sdks/otel-bridge/

For agents: Read this before adding Sypnia to a Node or Next.js app that already registers OpenTelemetry (NodeSDK, @vercel/otel), or that needs Prisma, MySQL, MongoDB or Redis spans; it gives the setup code, what the bridge adds over a plain OTLP exporter, the measured cost of the OpenTelemetry SDK and the rule of one tracer per process.

This page is for whoever runs a Node or Next.js app that **already uses OpenTelemetry**, or that wants OpenTelemetry's automatic instrumentations for libraries Sypnia's own SDK does not cover (Prisma, MySQL, MongoDB, Redis, queues). `@sypnia/telemetry/otel` is a small package that plugs Sypnia into the OpenTelemetry SDK you run: a span processor that sends to Sypnia, and a propagator that reads the browser's session. It is open source (MIT) and identical for the open-source engine and for Sypnia Cloud.

**At the end you will have:** the spans of your OpenTelemetry setup in Sypnia's traces and performance numbers, each trace joined to the browser session that started it and to the person in it, exceptions as problems, and your other OpenTelemetry backends, if any, still receiving everything as before.

> **In plain words**
>
> OpenTelemetry is a widely used open standard for following a request through a system. Some apps already have it set up. This package lets those apps send what they already collect to Sypnia too, instead of installing a second, separate tracer.

## Which one to use

| Your service                                                                     | Use                                                                                                                                                                                     |
| -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Node or Next.js, no OpenTelemetry today                                          | [`@sypnia/telemetry/node`](https://telemetry.docs.sypnia.com/sdks/node) or [`@sypnia/telemetry/next`](https://telemetry.docs.sypnia.com/sdks/nextjs). Lighter, nothing else to install. |
| Node or Next.js, OpenTelemetry already registered                                | **This bridge.** Keep your setup and add Sypnia to it.                                                                                                                                  |
| Node or Next.js, and you need spans for Prisma, MySQL, MongoDB, Redis or a queue | **This bridge**, with those instrumentations, if their cost is worth it to you. See [What it costs](#what-it-costs).                                                                    |
| Python, Go, PHP, Rust, Java, anything else                                       | Your language's OpenTelemetry SDK with its OTLP exporter pointed at Sypnia: [OpenTelemetry](https://telemetry.docs.sypnia.com/sdks/opentelemetry).                                      |

In every case the browser runs the [browser SDK](https://telemetry.docs.sypnia.com/sdks/browser), and one trace id joins the browser's call with the server's spans.

## Install

**npm**

```bash
npm install @sypnia/telemetry
```

**pnpm**

```bash
pnpm add @sypnia/telemetry
```

**yarn**

```bash
yarn add @sypnia/telemetry
```

**bun**

```bash
bun add @sypnia/telemetry
```

It needs the OpenTelemetry API (`@opentelemetry/api` 1.x) and an OpenTelemetry SDK for tracing (`@opentelemetry/sdk-trace-base` 2.x, which `@opentelemetry/sdk-node` and `@vercel/otel` include). It brings no exporter of OpenTelemetry's: it sends to Sypnia itself.

## Set it up in Node

If you have no OpenTelemetry setup yet, this is a complete one. If you have, add the marked lines to yours.

```bash
npm install @sypnia/telemetry @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node
```

`src/instrument.ts`

```ts
import { NodeSDK } from '@opentelemetry/sdk-node';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { sypnia } from '@sypnia/telemetry/otel';

const s = sypnia({
  project: process.env.SYPNIA_PROJECT_KEY,
  service: 'shop-api',
  environment: process.env.SYPNIA_ENVIRONMENT ?? 'production',
  release: process.env.SYPNIA_RELEASE,
});

new NodeSDK({
  spanProcessors: [s.spanProcessor],
  textMapPropagator: s.propagator,
  instrumentations: [
    getNodeAutoInstrumentations({
      '@opentelemetry/instrumentation-fs': { enabled: false },
      '@opentelemetry/instrumentation-dns': { enabled: false },
      '@opentelemetry/instrumentation-net': { enabled: false },
    }),
  ],
}).start();
```

`src/server.ts`

```ts
import './instrument';
import express from 'express';

const app = express();
app.post('/api/checkout', checkout);
app.listen(3000);
```

Self-hosted: add `endpoint: 'https://sypnia.example.com'` to `sypnia({…})`. The options and environment variables are the same as the Node SDK's: `project` (`SYPNIA_PROJECT_KEY`), `endpoint` (`SYPNIA_ENDPOINT`), `service` (`SYPNIA_SERVICE`, else the `service.name` your OpenTelemetry resource has), `environment` (`SYPNIA_ENVIRONMENT`), `release` (`SYPNIA_RELEASE`), `debug`, `enabled`.

A project in ES modules (`"type": "module"`) needs OpenTelemetry's loader hook for most instrumentations to see the libraries: start Node with `--import` and the instrument file as JavaScript (`node --import ./dist/instrument.js dist/server.js`), and follow OpenTelemetry's documentation for the hook of your version. That hook is part of the startup cost measured below.

If you already send to another backend, keep its processor or exporter next to Sypnia's: `spanProcessors: [s.spanProcessor, yourProcessor]`. Each receives every span.

## Set it up in Next.js

With `@vercel/otel`, the usual way to register OpenTelemetry in Next.js:

`instrumentation.ts`

```ts
import { registerOTel } from '@vercel/otel';
import { sypnia } from '@sypnia/telemetry/otel';

export function register() {
  const s = sypnia();
  registerOTel({ serviceName: 'shop-web', spanProcessors: [s.spanProcessor], propagators: [s.propagator] });
}

export { onRequestError } from '@sypnia/telemetry/otel/next';
```

In `registerOTel`, `spanProcessors` replaces `@vercel/otel`'s default processors, so `[s.spanProcessor]` sends spans to Sypnia only. If the app already exports elsewhere through those defaults (Vercel's own trace view, or an exporter set with the `OTEL_EXPORTER_OTLP_*` variables), keep them with `'auto'` and add Sypnia's processor after it:

```ts
registerOTel({ serviceName: 'shop-web', spanProcessors: ['auto', s.spanProcessor], propagators: [s.propagator] });
```

Then the `OTEL_EXPORTER_OTLP_*` variables must not point at Sypnia too, or each span arrives twice.

`sypnia()` with no options takes the key, the address, the environment and the release from [`withSypnia`](https://telemetry.docs.sypnia.com/sdks/nextjs#withsypnianextconfig-options) in `next.config.ts`, like the browser's `init()`. Keep `withSypnia` and `instrumentation-client.ts` exactly as in [Next.js](https://telemetry.docs.sypnia.com/sdks/nextjs): the browser side and the source maps do not change. Do not also export `register` from `@sypnia/telemetry/next/server`: that would be a second tracer. The option names of `registerOTel` are `@vercel/otel`'s; check its documentation for your version.

Next.js emits its own OpenTelemetry spans (renders, route resolution, `fetch` caching) once a tracer is registered; with the bridge they reach Sypnia too. Code on the Edge runtime is not covered, as with `@sypnia/telemetry/next`.

## Check that it works

1. Add `debug: true` to `sypnia({…})` and start your app.
2. Call a route: `curl -i http://localhost:3000/api/checkout -X POST`.
3. Within 2 seconds the console prints a line such as `exported 7 spans (200)`. The number depends on the instrumentations you turned on. A `401` means the key is wrong.
4. Within 10 minutes the route is listed in Performance and its trace is in Traces.

## What it adds to a plain exporter

Any OpenTelemetry exporter can send to Sypnia without this package ([OpenTelemetry](https://telemetry.docs.sypnia.com/sdks/opentelemetry)). The bridge does what an exporter cannot know to do:

|                                    | A plain OTLP exporter                                                 | With `@sypnia/telemetry/otel`                                                                                                                                  |
| ---------------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The browser's trace                | Joins, through `traceparent`                                          | Joins, through `traceparent`                                                                                                                                   |
| The browser's session              | Only if you copy `x-sypnia-session` to `session.id` yourself          | Read by the propagator and set as `session.id` on every server span                                                                                            |
| Person and account                 | Not set                                                               | `identify()` sets `user.id` and `sypnia.account.id`                                                                                                            |
| Environment and release            | Through `OTEL_RESOURCE_ATTRIBUTES`                                    | The same options as every Sypnia SDK                                                                                                                           |
| Query strings, full URLs, SQL text | Leave your server, and the engine drops them on arrival               | Dropped before they leave your server                                                                                                                          |
| Messages of failed calls           | Leave your server as they are, and the engine redacts them on arrival | Redacted before they leave your server, all of them. The bridge reads no answers, so the database error details of `@sypnia/telemetry/node` are not part of it |
| A request's spans                  | Can be split across exports                                           | Exported together, at most 200 per request                                                                                                                     |
| Usage limits                       | Spans past the limit are refused (`partialSuccess`)                   | `Sypnia-Slow-Down` obeyed: only spans with a failure are sent until the date it names                                                                          |
| Encoding                           | What you configure                                                    | Protobuf, gzipped                                                                                                                                              |

The `sypnia.*` attributes it sets are listed in the [semantic conventions](https://telemetry.docs.sypnia.com/reference/semantic-conventions).

The propagator reads and writes W3C `traceparent` (and `tracestate`), like OpenTelemetry's own, so other services keep continuing your traces. It reads `x-sypnia-session` and never forwards it.

## The functions you call

```ts
import { identify, reportError } from '@sypnia/telemetry/otel';
```

- `identify({ person: { id }, account?: { id } })` sets the person and the account on the current request's server span. Only ids: names and e-mail addresses are never sent from the server. You need it only for requests that do not come from an identified browser session. See [Identifying people](https://telemetry.docs.sypnia.com/sdks/identifying-people).
- `reportError(error)` records an `exception` event, with its stack, on the current span. Use it where your framework catches errors, as in [Node, Errors](https://telemetry.docs.sypnia.com/sdks/node#errors).

For your own steps, use OpenTelemetry's API (`tracer.startActiveSpan`), as you already do.

## What it costs

With the bridge you run the OpenTelemetry SDK and the instrumentations you choose. That cost is OpenTelemetry's, and it is your choice. Measured on 2026-11-15, on one machine, against a light tracer of our own (method and full table on [Node, What it costs](https://telemetry.docs.sypnia.com/sdks/node#what-it-costs)):

|                                           | Light own tracer | OpenTelemetry Node SDK 2.12, HTTP instrumentation, JSON exporter |
| ----------------------------------------- | ---------------- | ---------------------------------------------------------------- |
| CPU added per request                     | ≈ +0.15 ms       | ≈ +0.55–0.75 ms                                                  |
| Requests served when the CPU is the limit | −10 %            | −40 %                                                            |
| Time added before the server listens      | ≈ 0              | +600–800 ms                                                      |
| Memory added                              | +34 MB           | +60–62 MB                                                        |
| Data sent per 1,000 requests              | 278 KB           | 2,560 KB                                                         |

Two things in that test are not what the bridge does: the bridge sends protobuf, not JSON, so it sends less; and each instrumentation you add costs more on top. The bridge's own work (enriching, redacting and encoding spans) has a target of **under 0.1 ms per request**, to be measured on the real package. On serverless, the startup row is what every cold start pays.

### Which instrumentations are worth it

| Instrumentation                            | Worth it when                                            | Note                                                            |
| ------------------------------------------ | -------------------------------------------------------- | --------------------------------------------------------------- |
| `http`, `undici` (fetch)                   | Always: they make the server span and the outgoing calls | This is what was measured                                       |
| `express`, `fastify`, `koa`, `nestjs-core` | You want a span per middleware or handler                | The route name is there without them                            |
| `@prisma/instrumentation`                  | You use Prisma                                           | Sypnia's own SDK does not see Prisma's engine                   |
| `mysql2`, `mongodb`, `ioredis`, `redis`    | You use them                                             | Sypnia's own SDK does not trace them by itself: this is the way |
| `pg`                                       | You use Postgres and the bridge                          | Same spans as Sypnia's own SDK                                  |
| `graphql`                                  | You need resolver timings                                | Many spans per request: turn it on when you look for something  |
| `aws-sdk`, `kafkajs`, `amqplib`            | Workers and queues                                       | Their spans start traces of their own                           |
| `fs`, `dns`, `net`                         | Almost never                                             | Many spans, little to learn: leave them off, as in the example  |

Each one adds spans, so it also adds to what you send. See [Sampling and quotas](https://telemetry.docs.sypnia.com/sdks/sampling-and-quotas).

## Beside `@sypnia/telemetry/node`

**One tracer per process.** Use the bridge or `@sypnia/telemetry/node` in a service, not both. If both are installed and the bridge's processor is registered, `@sypnia/telemetry/node` sees it, leaves tracing to OpenTelemetry and prints one line with `debug: true`, so nothing is traced twice. Different services can make different choices: a request that goes from a service with `@sypnia/telemetry/node` to one with the bridge is one trace, through `traceparent`.

Moving from the bridge to `@sypnia/telemetry/node` later, or back, changes no data: both send the same attributes to the same endpoint.

## Next
