Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 76 additions & 9 deletions static/app/gettingStartedDocs/python/python.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ export const agentMonitoringOnboarding: OnboardingConfig = {
packageName = 'sentry-sdk[langgraph]';
} else if (selected === 'litellm') {
packageName = 'sentry-sdk[litellm]';
} else if (selected === 'google_genai') {
packageName = 'sentry-sdk[google_genai]';
}

return [
Expand Down Expand Up @@ -571,28 +573,33 @@ sentry_sdk.init(
],
};

const manualStep: OnboardingStep = {
const googleGenAIStep: OnboardingStep = {
type: StepType.CONFIGURE,
content: [
{
type: 'text',
text: tct(
'If you are not using a supported SDK integration, you can instrument your AI calls manually. See [link:manual instrumentation docs] for details.',
{
link: (
<ExternalLink href="https://docs.sentry.io/platforms/python/tracing/instrumentation/custom-instrumentation/ai-agents-module/" />
),
}
'Import and initialize the Sentry SDK - add the GoogleGenAIIntegration to your integrations list:',
{code: <code />}
),
},
{
type: 'code',
language: 'python',
code: `
import sentry_sdk
from sentry_sdk.integrations.google_genai import GoogleGenAIIntegration

sentry_sdk.init(dsn="${params.dsn.public}", traces_sample_rate=1.0)
`,
sentry_sdk.init(
dsn="${params.dsn.public}",
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=[
GoogleGenAIIntegration(),
],
)`,
},
],
};
Expand Down Expand Up @@ -724,6 +731,32 @@ sentry_sdk.init(
],
};

const manualStep: OnboardingStep = {
type: StepType.CONFIGURE,
content: [
{
type: 'text',
text: tct(
'If you are not using a supported SDK integration, you can instrument your AI calls manually. See [link:manual instrumentation docs] for details.',
{
link: (
<ExternalLink href="https://docs.sentry.io/platforms/python/tracing/instrumentation/custom-instrumentation/ai-agents-module/" />
),
}
),
},
{
type: 'code',
language: 'python',
code: `
import sentry_sdk

sentry_sdk.init(dsn="${params.dsn.public}", traces_sample_rate=1.0)
`,
},
],
};

const selected = (params.platformOptions as any)?.integration ?? 'openai_agents';
if (selected === 'openai') {
return [openaiSdkStep];
Expand All @@ -740,6 +773,9 @@ sentry_sdk.init(
if (selected === 'litellm') {
return [liteLLMStep];
}
if (selected === 'google_genai') {
return [googleGenAIStep];
}
if (selected === 'manual') {
return [manualStep];
}
Expand Down Expand Up @@ -968,6 +1004,34 @@ response = completion(
messages=[{"role": "user", "content": "Tell me a joke"}],
)
print(response.choices[0].message.content)
`,
},
],
};

const googleGenAIVerifyStep: OnboardingStep = {
type: StepType.VERIFY,
content: [
{
type: 'text',
text: t(
'Verify that agent monitoring is working correctly by making a simple Google Gen AI API call:'
),
},
{
type: 'code',
language: 'python',
code: `
from google.genai import Client

client = Client()
response = client.models.generate_content(
model="gemini-2.0-flash-exp",
contents="What's the weather like in San Francisco?"
)

print(response)

`,
},
],
Expand Down Expand Up @@ -1025,6 +1089,9 @@ with sentry_sdk.start_span(op="gen_ai.chat", name="chat o3-mini") as span:
if (selected === 'litellm') {
return [liteLLMVerifyStep];
}
if (selected === 'google_genai') {
return [googleGenAIVerifyStep];
}
if (selected === 'manual') {
return [manualVerifyStep];
}
Expand Down
1 change: 1 addition & 0 deletions static/app/views/insights/agents/views/onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export function Onboarding() {
{label: 'OpenAI SDK', value: 'openai'},
{label: 'OpenAI Agents SDK', value: 'openai_agents'},
{label: 'Anthropic SDK', value: 'anthropic'},
{label: 'Google Gen AI SDK', value: 'google_genai'},
{label: 'LangChain', value: 'langchain'},
{label: 'LangGraph', value: 'langgraph'},
{label: 'LiteLLM', value: 'litellm'},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const knownSpanOrigins = {
'auto.ai.langgraph',
'auto.ai.anthropic',
'auto.ai.litellm',
'auto.ai.google_genai',
],
javascript: ['auto.ai.anthropic', 'auto.ai.openai', 'auto.vercelai.otel'],
} as const;
Expand Down Expand Up @@ -136,6 +137,8 @@ const pythonIntegrationLinks: Record<PythonSpanOrigin, string> = {
'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.google_genai':
'https://docs.sentry.io/platforms/python/integrations/google-genai/',
};

function PythonContent({
Expand Down
Loading