Node.js
The Sophonz Node.js SDK brings OpenTelemetry-based observability to Node.js server applications with automatic instrumentation, framework middleware, and exception capture.
@sophonz/node-sdk is a complete OpenTelemetry distribution for Node.js servers. It wires up automatic instrumentation, traces, metrics, and logs, and adds Sophonz-specific extras such as console capture, exception capture, and Express/Koa request middleware. It also bundles the API tools from the latest stable official @opentelemetry/api, ready to import.
What you get
- Automatic instrumentation for HTTP/HTTPS, popular libraries, and Node.js runtime metrics via OpenTelemetry auto-instrumentations.
- Framework middleware (
sophonzExpressMiddleware,sophonzKoaMiddleware) that enriches every request span with baggage, client IP, user-agent, and your own custom attributes. - Exception capture for uncaught exceptions and unhandled rejections, plus Express/Koa error handlers.
- Console capture that turns
console.*calls into structured logs. - Sentry integration for projects already using Sentry SDKs.
- The official OpenTelemetry API — the API tools from the latest stable
@opentelemetry/api(trace,context,propagation,metrics,logs), bundled and ready to import from the SDK.
How it works
The SDK can be initialized two ways:
- Programmatically — call
init()at the very top of your entry file. - Via the preload binary — run your app with
opentelemetry-instrument(ornode -r .../opentelemetry-instrument.js) so instrumentation is applied before any module loads.
Once running, the SDK exports telemetry over OTLP to the Sophonz collector. Configure it through SDKConfig options or the matching SOPHONZ_* / OTEL_* environment variables.
TIP — Where to next
New to the SDK? Start with Installation, then read the Configuration and Middleware guides.