Install
init(), then either auto_instrument()
(best-effort for a small set of libraries) or the individual instrument_*
functions for exactly what you want traced.
Initialize
Calltracelane.init(...) once at application start — before the code you want
traced runs. endpoint and api_key are required (there is no env-var
auto-read).
endpoint is any OTLP HTTP receiver you can reach — Tracelane Cloud’s gateway
(https://gateway.tracelane.dev), a self-hosted Tracelane ingest, or a local
collector such as http://localhost:4318.
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; it is on by default for new keys.Instrument what you want traced
Constructing a client does not patch it. Afterinit(), you have two options.
Option A — auto_instrument() (best-effort, 5 libraries)
auto_instrument() attempts anthropic, openai, litellm, langgraph, and
claude_code, printing each outcome to stderr. Anthropic/OpenAI only wrap a new
default client; wrap your own clients explicitly. Install tracelane[langgraph]
to capture graph and child runs via OpenInference’s LangChain callbacks and your
existing exporter. Inputs/outputs are redacted; custom metadata may still be
captured. Existing LangChain instrumentation keeps its configuration. If the
integration is unavailable, call instrument_langgraph(graph) after compilation
for graph-level spans. See LangGraph for a runnable
example. All other adapters need explicit calls.
Option B — explicit instrument_* calls
There are 28 instrument_* functions. Each takes the object you constructed and
patches it in place. Call after init().
Adapters
LLM providers
Agent frameworks
Construct the chain/graph/agent, then instrument it — none of this is instrumented for you.Memory & vector stores
Tools & browser
Custom spans
The SDK sets up a standard OpenTelemetry tracer provider, so custom spans use the OpenTelemetry Python API directly — the SDK ships no custom-span wrapper:Sampling
Shutdown
Testing
Nothing is patched until you callinit() and instrument_*, so a test that
skips them emits no spans — no disable flag needed. To assert on emitted spans,
register your own provider with a standard in-memory exporter before
instrumenting, then read the finished spans: