Install
Fastest path — route through the gateway (no SDK)
For Tracelane Cloud, the shortest path to your first trace needs no SDK at all: point your existing client’s base URL at the gateway and use yourtlane_… key. The gateway routes the call and captures the trace.
Initialize
Callinit() once, before any instrumented library is used. The SDK is built
on the OpenTelemetry Node SDK and runs anywhere that runtime does (Node.js, Bun).
endpoint to that instead —
http://localhost:4318, http://otel-collector.internal:4318, and so on.
Your key needs the
ingest scope. Keys minted before scopes existed carry
the full API surface and work as-is. A key you scoped to chat and read does
not — the gateway answers 403 insufficient_scope and names ingest in the
body. Tick Ingest in Settings → API Keys when you mint the key; it is on
by default for new keys.
Call
shutdown() on exit to flush pending spans (a flush is also registered on
beforeExit).
Adapters
Instrumentation is explicit: afterinit(), wrap each client with its
instrument* function. Wrapping patches the client in place — what’s traced is
exactly what you opt in.
Anthropic
OpenAI
OpenAI Agents SDK
LangChain.js
Vercel AI SDK
Use the gateway as the base URL:instrumentVercelAI(ai) is not supported: the ai module’s namespace object is
read-only, so it cannot be patched. Use the gateway base URL above.
MCP (Model Context Protocol)
Zero-config autoInstrument() is not in v1 — calling it throws with a
pointer to this explicit API.
Custom spans
The SDK sets up a standard OpenTelemetry tracer provider, so custom spans use@opentelemetry/api directly — there is no Tracelane-specific wrapper:
Next.js App Router
Initialize ininstrumentation.ts (Next.js 15 instrumentation hook) so it
runs once per server process:
next.config.ts change is needed. The instrumentation hook is stable in
Next.js 15 — the experimental.instrumentationHook flag was removed, and
setting it now raises an invalid-config warning.
Testing
The SDK builds on the OpenTelemetry Node SDK, so you assert on emitted spans with a standard in-memory exporter — no Tracelane-specific test API needed. Register your own provider with anInMemorySpanExporter before wrapping a
client, then read the finished spans:
ESM / CJS
The package ships dual ESM + CJS. No extra configuration needed. Works with"type": "module" and without.