Skip to main content
Supported frameworks emit child spans automatically once a tracer provider is registered. Your job is:
  1. Install @uselemma/tracing (TypeScript) or uselemma-tracing (Python)
  2. Register the Lemma tracer provider at startup
  3. Wrap your top-level agent function with agent() to create a run boundary
No manual span creation needed for the framework’s own operations.

Setup

Install

npm install @uselemma/tracing

Register the tracer provider

Call registerOTel() / register_otel() once at startup, before any application code that creates spans.
// instrumentation.ts
export async function register() {
  if (process.env.NEXT_RUNTIME === "nodejs") {
    const { registerOTel } = await import("@uselemma/tracing");
    registerOTel();
  }
}
Set LEMMA_API_KEY and LEMMA_PROJECT_ID environment variables. Find them in your Lemma project settings.

Pick your framework

Each Integration page covers framework-specific setup: how to enable telemetry, streaming patterns, and any extra instrumentors needed.

Vercel AI SDK

Enable experimental_telemetry on generateText / streamText calls. Built-in OTel support — no extra instrumentor required.

OpenAI Agents SDK

Wrap run() with agent(). The SDK’s own tracing emits child spans automatically.

OpenAI Agents SDK (Python)

Use instrument_openai_agents() before importing agents. Works with tool calling, handoffs, and guardrails.

LangChain

Register LangChainInstrumentor after register_otel(). Every chain step, LLM call, tool, and retriever emits a child span automatically.

Common patterns


Next Steps