Configure Telemetry: Auto-Instrumentation
Auto-instrumentation traces every LLM call, tool invocation, and chain or graph execution in supported frameworks without touching your application code. If you’re building on LangChain, LangGraph, Microsoft Agent Framework, or Pydantic AI, this is the fastest path to a working trace.
What You’ll Achieve
- Traces for every LLM call, tool call, and (for LangGraph/MAF) agent/graph step
- No decorators, no manual span creation
- One line of code:
auto_instrument()
Prerequisites
RhesisClientinitialized: see Configuring Telemetry- The pip extra for your framework installed
Supported Frameworks
| Framework | auto_instrument key | pip extra | Mechanism |
|---|---|---|---|
| LangChain | langchain | langchain | Callback handler + tool patching |
| LangGraph | langgraph | langgraph | Shared LangChain callback + graph method patching |
| Microsoft Agent Framework | `agent_framework` (alias `maf`) | agent-framework | OTel span translation (gen_ai.* → ai.*) |
| Pydantic AI | pydantic_ai | pydantic-ai | OTel span translation |
Using a different framework? Auto-instrumentation won’t cover it. Go to Decorators instead.
Setup
Install the framework extra
Initialize the client
Enable auto-instrumentation
Call auto_instrument() once, right after creating RhesisClient, before your framework code runs. It patches the framework’s entry points, so anything constructed beforehand (e.g. a chain built at import time) is still traced: the patching targets invocation, not construction.
Use your framework normally
Verify traces are arriving
Open the Rhesis dashboard’s trace view for your project. A single llm.invoke call should appear as an ai.llm.invoke span with model name, provider, and token counts populated within a few seconds (traces flush every 5s by default).
How It Works
Callback-based (LangChain/LangGraph): the SDK registers a global callback handler that intercepts on_chat_model_start, on_tool_start, on_chain_start, and equivalents, creating properly-nested Rhesis-convention spans directly. LangGraph reuses the LangChain callback rather than creating its own, so auto_instrument("langgraph") alone already covers chains, tools, and LLM calls invoked from graph nodes.
Span-translating (MAF/Pydantic AI): these frameworks already emit standard OpenTelemetry GenAI spans (gen_ai.*). The SDK wraps the OTLP exporter with a translating exporter that rewrites span names and attributes into the Rhesis ai.* schema at export time, and synthesizes ai.agent.handoff spans from handoff_to_* tool-call patterns.
Combining with Decorators
Auto-instrumentation and @observe/@endpoint work together: the SDK deduplicates so you never get two spans for the same LLM call:
Disabling
You have working traces. Multi-agent system? See Multi-Agent Tracing. Multi-turn chat? See Tracking Multi-Turn Conversations.
Related:
- Auto-Instrumentation Reference - full API surface and per-framework examples
- Microsoft Agent Framework - handoff tracing and content-capture options
- Configuring Telemetry - back to the mode overview