Skip to main content

When is Agent Tracing instrumented automatically?

Learn when enabling tracing in the Sentry SDK automatically captures AI agent, LLM, and gen AI spans, and when you need extra setup.

Issue

I enabled tracing in the Sentry SDK and want to know if Sentry captures my AI agent runs automatically. I'm looking for my LLM calls, gen AI spans, and AI agent activity in Agent Tracing (formerly AI Agent Monitoring or LLM Monitoring). I want to know if I need extra setup.

Applies To

  • All SaaS Customers

  • Agent Tracing

Resolution

Agent Tracing is instrumented automatically in the following cases:

  • JavaScript (Node.js) SDK 11.0.0 or later: The SDK instruments supported AI libraries, including OpenAI, Anthropic, Vercel AI SDK, LangChain, and LangGraph. See the Node.js Agent Tracing documentation.

  • Python: The SDK instruments most supported AI libraries, such as OpenAI, Anthropic, LangChain, and LangGraph, as soon as their packages are installed. You need to add LiteLLM, Mistral, and TypeSafe to your integrations list yourself. See the Python Agent Tracing documentation

  • Other platforms: Find your platform and its supported libraries in the Agent Tracing getting started guide.

On JavaScript SDK versions before 11.0.0, upgrade to 11.0.0. or later to get automatic instrumentation for supported libraries. For more information, please consult the supported library page.

For SDKs not listed above, you can manually instrument your agents. Use manual instrumentation for unsupported AI libraries or custom agent code. To set it up:

  1. Enable tracing in the Sentry SDK.

  2. Open the manual instrumentation guide for your platform: JavaScript (Node.js) or Python.

  3. Create agent spans around your AI calls, as the guide describes.

To group multi-turn chats in Conversations, set a conversation ID for each chat. In JavaScript, call Sentry.setConversationId() at the start of each request that makes AI calls. Some integrations set it for you. See Tracking Conversations.

Did this answer your question?