Requirements: Node.js ≥ 18.0.0 · TypeScript ≥ 5 (optional) · CJS and ESM both supported
Installation
Quick start
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 theconfigure 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
OnceTracelit.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)
WhenTracelit.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.