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 — one call to auto_instrument(), no decorators or manual spans. If you’re building on LangChain, LangGraph, Microsoft Agent Framework, or Pydantic AI, this is the fastest path to a working trace.
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.
- Microsoft Agent Framework handoffs are recognized from
handoff_to_*tool-call spans. - Pydantic AI handoffs are recognized when one agent invokes another within a tool call. Native instrumentation covers
run(),run_sync(), andrun_stream(), including model and tool spans.
Pydantic AI tracing uses instrumentation schema version 5 and never records binary
attachment content. Set RHESIS_DISABLE_CONTENT_CAPTURE=1 before calling
auto_instrument(...) to omit prompts, completions, and tool payloads as well.
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
Next Steps
- 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