Platforms
Node.js & Bun
Trace requests, collect logs and report errors from a Node.js or Bun service.
Node.js (24.11.1+) and Bun share the same entry point, @openperf/sdk/node. It builds on OpenTelemetry and sets up tracing, log collection and error reporting in one call.
Install the SDK
npm i @openperf/sdkCreate the instrument file
Put init in its own file so it runs before your app imports any libraries:
import { init } from "@openperf/sdk/node";
init({
dsn: process.env.OPENPERF_DSN,
environment: process.env.NODE_ENV,
release: process.env.APP_RELEASE,
});Without a dsn and without the OPENPERF_DSN variable, init does nothing, so the same file is safe to load locally. Copy the DSN from Settings → Projects → Connection.
Preload it before your app
Start with --import (ESM):
node --import ./instrument.mjs app.mjsFor CommonJS, name the file instrument.cjs, load the SDK with require("@openperf/sdk/node") and use --require:
node --require ./instrument.cjs app.cjsA library loaded before init is not traced.
See the first trace
Send a request to your app and open Traces in the dashboard. After a few seconds the request appears under its method and route, such as GET /users/:id.
What the SDK collects
| Data | Details |
|---|---|
| Requests | Incoming HTTP requests (Bun.serve, Express, Fastify, Koa, hapi, Restify, Connect, NestJS, GraphQL, gRPC, Socket.IO). |
| Outgoing HTTP | fetch, node:http and node:https calls, each carrying a traceparent header. |
| Databases and caches | PostgreSQL (pg), MySQL (mysql, mysql2), MongoDB (mongodb, mongoose), Redis (redis, ioredis), Memcached, Cassandra, Oracle Database, SQL Server (tedious) and Knex. |
| Queues | RabbitMQ (amqplib) and Kafka (kafkajs). |
| Cloud and AI | AWS SDK, AWS Lambda and OpenAI. |
| Logs | Records written with pino or bunyan, linked to the active trace. For winston, also install @opentelemetry/winston-transport. |
| Errors | Uncaught exceptions, unhandled promise rejections and framework request errors. |
The default set is the OpenTelemetry Node.js auto-instrumentations plus Fastify (without fs, dns, net, router, host metrics or runtime metrics). Pass extra ones in instrumentations.
Bun specifics
Bun.serve& streams:routeshandlers produce traces named by method and route (GET /users/:id);text/event-streamspans stay open until the stream ends or the client disconnects. StaticResponseroutes are not traced.- Hot reload:
bun --hotis supported without duplicating spans. - Library instrumentation: Because Bun has no ESM loader hooks,
initpreloads supported libraries listed inpackage.json(dependencies/devDependencies). Libraries not listed inpackage.json(or in bundled apps withoutnode_modules) are not auto-instrumented.
Crashes and shutdown
Queued telemetry flushes on normal exit, SIGTERM, SIGINT and crashes (up to a 2-second wait). If your app calls process.exit() directly or runs in a serverless handler, await flush() first:
import { flush } from "@openperf/sdk/node";
await flush();
process.exit(0);Apps that already use OpenTelemetry
If another SDK already registered OpenTelemetry, init prints a warning and stays off. Call OpenPerf's init first, or export directly over OpenTelemetry.