Skip to main content
Requirements: Node.js ≥ 18.0.0 · TypeScript ≥ 5 (optional) · CJS and ESM both supported

Installation


Quick start

The SDK must be initialised before any other modules that need auto-instrumentation (Express, Mongoose, Redis, etc.). Create a dedicated init file and import it as the very first line of your entry point.
1

Create your Tracelit initializer

tracelit.ts
2

Import the initializer first in your entry point

server.ts
3

Set your environment variables

.env

Configuration reference

All options can be set in the configure callback or via environment variables.

Custom resource attributes


Tracing

Manual spans

Tracelit.tracer is a standard OpenTelemetry Tracer and supports the full OTel JS API.

Automatic instrumentation

Tracelit.start() enables every auto-instrumentation package present in your node_modules via @opentelemetry/auto-instrumentations-node. No extra config needed.

Metrics

Tracelit.metrics returns null before start() is called or when the SDK is disabled — optional chaining (?.) is safe everywhere.

Counter

Histogram

Gauge

Observable gauge (callback-based)

Use when the value is expensive to compute and should only be read on the export interval:

HTTP server metrics (Express middleware)

Attributes on all HTTP metrics: http.method, http.route, http.status_code.

Automatic process metrics

Once Tracelit.start() is called, the following are collected with no extra code: Both pollers use unref()’d timers and will not prevent your process from exiting.

Logging

Console bridge (automatic)

When Tracelit.start() is called, all console.debug/log/info/warn/error calls are automatically forwarded to the OTel LoggerProvider. Original console output is preserved and logs are correlated with the active trace via trace_id and span_id.

Winston transport

Pino destination


Sampling and error guarantee

Error spans are always exported, even when the parent trace is outside the sample ratio. The SDK uses ErrorAlwaysOnSampler + ErrorSpanProcessor to guarantee this — no configuration required.

Disabling in tests


TypeScript / JavaScript compatibility

The package ships as dual CJS + ESM bundles with full TypeScript declaration files.

Complete example


GitHub

Source code and issue tracker: github.com/Tracelit-AI/tracelit-node