sentry-setup-ai-monitoring
Setup Sentry AI Agent Monitoring in any project. Use when asked to monitor LLM calls, track AI agents, track conversations, or instrument OpenAI/Anthropic/Vercel AI/LangChain/Google GenAI/Pydantic AI. Detects installed AI SDKs and configures appropriate integrations.
Security Assessment
Detected risks:
About sentry-setup-ai-monitoring
A feature-setup skill that configures Sentry AI Agent Monitoring in a project so it can track LLM calls, agent executions, tool usage, and token consumption. It activates when asked to monitor LLM calls, track AI agents or conversations, or instrument SDKs such as OpenAI, Anthropic, Vercel AI, LangChain, Google GenAI, or Pydantic AI, and it works by detecting installed AI SDKs and configuring the appropriate integrations. The skill notes that the SDK versions, API names, and code samples it contains are examples and should be verified against docs.sentry.io before implementing, since APIs and minimum versions may change.
AI monitoring requires tracing to be enabled (a non-zero traces sample rate), and for multi-turn chats the skill recommends setting a conversation ID since Sentry uses gen_ai.conversation.id to group related AI spans into Conversations. A prominent data-capture warning explains that recording prompts and outputs captures user content that is likely PII; before enabling send-default-PII or per-integration prompt/output capture, the agent must confirm the privacy policy permits it, that captured data complies with regulations like GDPR and CCPA, and that retention settings are appropriate, and it must ask the user for explicit confirmation. It also advises against using a 100% sample rate in production, suggesting a lower rate or a tracesSampler function. A detection-first step greps package.json or requirements/pyproject files to find installed AI SDKs, followed by a sampling check; if the sample rate is below 1.0 with no sampler, it offers to set up a tracesSampler that keeps AI traces at 100% because agent runs are sampled as complete span trees.
Supported SDK tables cover JavaScript integrations (openAIIntegration, anthropicAIIntegration, vercelAIIntegration, langChainIntegration, langGraphIntegration, googleGenAIIntegration) with minimum Sentry SDK versions, and Python integrations that auto-enable when the package is installed, with litellm noted as requiring explicit registration. Configuration examples show Node.js auto-enabled setup, manual client wrapping for browser and Next.js via instrumentOpenAiClient, LangChain/LangGraph, and Vercel AI with experimental_telemetry per call, plus Python init with stream_gen_ai_spans. For unsupported SDKs, manual instrumentation follows the Sentry Conventions for gen_ai.* attributes, with span types for individual LLM calls, agent invocation, tool execution, and agent handoffs.
FAQ
What is the prerequisite for AI monitoring?
It requires tracing to be enabled, meaning a non-zero traces sample rate (`tracesSampleRate > 0`). For multi-turn chats it also recommends setting a conversation ID, since Sentry uses gen_ai.conversation.id to group related AI spans into Conversations.
How does it handle prompt and output data that may be PII?
The skill warns that recording prompts and outputs captures likely-PII user content. Before enabling send-default-PII or per-integration capture, it requires confirming privacy policy, regulatory compliance, and retention, and asks the user for explicit confirmation rather than enabling it by default.
Which AI SDKs are supported?
JavaScript supports openai, @anthropic-ai/sdk, ai (Vercel), @langchain/*, @langchain/langgraph, and @google/genai via named integrations; Python auto-enables for openai, anthropic, langchain/langgraph, huggingface_hub, google-genai, pydantic-ai, and mcp, while litellm requires an explicit integration.
Why might it suggest a tracesSampler?
Because agent runs are sampled as complete span trees, so if the root span is dropped all child gen_ai spans are lost. If the sample rate is below 1.0 with no sampler configured, it offers to set up a tracesSampler that keeps AI traces at 100% while sampling other traffic at the current rate.
What if no supported SDK is detected?
It falls back to manual instrumentation following the Sentry Conventions for gen_ai.* attributes, using span types such as gen_ai.{operation} for individual LLM calls, gen_ai.invoke_agent, gen_ai.execute_tool, and gen_ai.handoff.
Install sentry-setup-ai-monitoring
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
getsentry/sentry-for-ai