diff --git a/static/app/gettingStartedDocs/python/python.tsx b/static/app/gettingStartedDocs/python/python.tsx index 9f4f631b61d5ee..0e4401688f2968 100644 --- a/static/app/gettingStartedDocs/python/python.tsx +++ b/static/app/gettingStartedDocs/python/python.tsx @@ -460,6 +460,8 @@ export const agentMonitoringOnboarding: OnboardingConfig = { packageName = 'sentry-sdk[langgraph]'; } else if (selected === 'litellm') { packageName = 'sentry-sdk[litellm]'; + } else if (selected === 'pydantic_ai') { + packageName = 'sentry-sdk[pydantic_ai]'; } return [ @@ -724,6 +726,50 @@ sentry_sdk.init( ], }; + const pydanticAiStep: OnboardingStep = { + type: StepType.CONFIGURE, + content: [ + { + type: 'text', + text: tct( + 'Import and initialize the Sentry SDK for [pydantic_ai:Pydantic AI] monitoring:', + { + pydantic_ai: ( + + ), + } + ), + }, + { + type: 'code', + language: 'python', + code: ` +import sentry_sdk +from sentry_sdk.integrations.pydantic_ai import PydanticAiIntegration + +sentry_sdk.init( + dsn="${params.dsn.public}", + environment="local", + traces_sample_rate=1.0, + # Add data like inputs and responses to/from LLMs and tools; + # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info + send_default_pii=True, + integrations=[ + PydanticAiIntegration(), + ], + # Disable OpenAI integration for correct token accounting + disabled_integrations=[OpenAIIntegration()], +)`, + }, + { + type: 'text', + text: t( + 'The Pydantic AI integration will automatically collect information about agents, tools, prompts, tokens, and models.' + ), + }, + ], + }; + const selected = (params.platformOptions as any)?.integration ?? 'openai_agents'; if (selected === 'openai') { return [openaiSdkStep]; @@ -740,6 +786,9 @@ sentry_sdk.init( if (selected === 'litellm') { return [liteLLMStep]; } + if (selected === 'pydantic_ai') { + return [pydanticAiStep]; + } if (selected === 'manual') { return [manualStep]; } @@ -973,6 +1022,32 @@ print(response.choices[0].message.content) ], }; + const pydanticAiVerifyStep: OnboardingStep = { + type: StepType.VERIFY, + content: [ + { + type: 'text', + text: t( + 'Verify that agent monitoring is working correctly by creating a Pydantic AI agent:' + ), + }, + { + type: 'code', + language: 'python', + code: ` +from pydantic_ai import Agent + +# Create an agent with OpenAI model +agent = Agent('openai:gpt-4o-mini') + +# Run the agent +result = agent.run_sync('Tell me a joke') +print(result.data) +`, + }, + ], + }; + const manualVerifyStep: OnboardingStep = { type: StepType.VERIFY, content: [ @@ -1025,6 +1100,9 @@ with sentry_sdk.start_span(op="gen_ai.chat", name="chat o3-mini") as span: if (selected === 'litellm') { return [liteLLMVerifyStep]; } + if (selected === 'pydantic_ai') { + return [pydanticAiVerifyStep]; + } if (selected === 'manual') { return [manualVerifyStep]; } diff --git a/static/app/views/insights/agents/views/onboarding.tsx b/static/app/views/insights/agents/views/onboarding.tsx index 234bb9d0ca19da..bf594c15d7be2c 100644 --- a/static/app/views/insights/agents/views/onboarding.tsx +++ b/static/app/views/insights/agents/views/onboarding.tsx @@ -253,6 +253,7 @@ export function Onboarding() { {label: 'LangChain', value: 'langchain'}, {label: 'LangGraph', value: 'langgraph'}, {label: 'LiteLLM', value: 'litellm'}, + {label: 'Pydantic AI', value: 'pydantic_ai'}, {label: 'Manual', value: 'manual'}, ] : [ diff --git a/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/aiIOAlert.tsx b/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/aiIOAlert.tsx index 1b7ccc3fb2c160..757573010a2079 100644 --- a/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/aiIOAlert.tsx +++ b/static/app/views/performance/newTraceDetails/traceDrawer/details/span/eapSections/aiIOAlert.tsx @@ -32,6 +32,7 @@ const knownSpanOrigins = { 'auto.ai.langgraph', 'auto.ai.anthropic', 'auto.ai.litellm', + 'auto.ai.pydantic_ai', ], javascript: ['auto.ai.anthropic', 'auto.ai.openai', 'auto.vercelai.otel'], } as const; @@ -136,6 +137,8 @@ const pythonIntegrationLinks: Record = { 'auto.ai.langgraph': 'https://docs.sentry.io/platforms/python/integrations/langgraph/', 'auto.ai.anthropic': 'https://docs.sentry.io/platforms/python/integrations/anthropic/', 'auto.ai.litellm': 'https://docs.sentry.io/platforms/python/integrations/litellm/', + 'auto.ai.pydantic_ai': + 'https://docs.sentry.io/platforms/python/integrations/pydantic-ai/', }; function PythonContent({