Skip to main content

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 your tlane_… key. The gateway routes the call and captures the trace.
That captures the model call. Use the SDK below when you want the shape of your agent — the planner step, each tool call, the summariser — as a nested trace rather than one span per model call. It exports OTLP to any endpoint you can reach: Tracelane Cloud’s gateway, a self-hosted Tracelane ingest, or your own collector (Jaeger, Tempo, …).

Initialize

Call init() 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).
For a self-hosted ingest or your own collector, set 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: after init(), wrap each client with its instrument* function. Wrapping patches the client in place — what’s traced is exactly what you opt in.

Anthropic

Tool use, streaming, vision, and beta features are all captured.

OpenAI

OpenAI Responses API and streaming are captured.

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 in instrumentation.ts (Next.js 15 instrumentation hook) so it runs once per server process:
No 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 an InMemorySpanExporter 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.