Skip to content

feat(backend): Add Sentry performance integrations for better tracing#11969

Closed
Otto-AGPT wants to merge 2 commits intodevfrom
fix/sentry-performance-integrations
Closed

feat(backend): Add Sentry performance integrations for better tracing#11969
Otto-AGPT wants to merge 2 commits intodevfrom
fix/sentry-performance-integrations

Conversation

@Otto-AGPT
Copy link
Contributor

@Otto-AGPT Otto-AGPT commented Feb 4, 2026

Changes 🏗️

  • Added FastApiIntegration() to sentry_sdk.init() — traces FastAPI request handling with detailed spans (middleware, route handlers, dependencies)
  • Added HttpxIntegration() to sentry_sdk.init() — traces outgoing HTTP calls (OpenAI, Anthropic, external APIs)
  • Added corresponding imports from sentry_sdk.integrations.fastapi and sentry_sdk.integrations.httpx

Checklist 📋

For code changes:

  • I have clearly listed my changes in the PR description
  • I have made a test plan
  • I have tested my changes according to the test plan:
    • No behavior change — only additional telemetry; verify spans appear in Sentry Performance after deploy
Example test plan
  • Create from scratch and execute an agent with at least 3 blocks
  • Import an agent from file upload, and confirm it executes correctly
  • Upload agent to marketplace
  • Import an agent from marketplace and confirm it executes correctly
  • Edit an agent from monitor, and confirm it executes correctly

For configuration changes:

  • .env.default is updated or already compatible with my changes
  • docker-compose.yml is updated or already compatible with my changes
  • I have included a list of my configuration changes in the PR description (under Changes)
Examples of configuration changes
  • Changing ports
  • Adding new services that need to communicate with each other
  • Secrets or environment variable changes
  • New or infrastructure changes such as databases

…erformance tracing

Adds FastApiIntegration and HttpxIntegration to Sentry SDK initialization to enable:
- Detailed span tracking for FastAPI request handling
- Automatic tracing of outgoing HTTP calls (OpenAI, external APIs, etc.)

This improves visibility in Sentry Performance for debugging slow requests and identifying bottlenecks in external API calls.
@Otto-AGPT Otto-AGPT requested a review from a team as a code owner February 4, 2026 22:47
@Otto-AGPT Otto-AGPT requested review from Pwuts and kcze and removed request for a team February 4, 2026 22:47
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Feb 4, 2026
@github-actions github-actions bot added platform/backend AutoGPT Platform - Back end size/s labels Feb 4, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

Walkthrough

The pull request adds FastApiIntegration and HttpxIntegration to Sentry's initialization configuration. This enables distributed tracing for FastAPI requests and outgoing HTTP calls to external APIs.

Changes

Cohort / File(s) Summary
Sentry Integrations
autogpt_platform/backend/backend/util/metrics.py
Added FastApiIntegration and HttpxIntegration imports and enabled them in Sentry setup for tracing FastAPI requests and outgoing HTTP calls.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

Suggested labels

platform/backend, Review effort 2/5

Poem

🐰 Hops with glee through trace routes
HTTP calls now shimmer bright
FastAPI spans dance in sight
Sentry watches all our might
Monitoring made just right!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding Sentry performance integrations (FastAPI and HTTPX) for improved tracing visibility.
Description check ✅ Passed The pull request description clearly explains the changes (adding FastAPI and HTTPX Sentry integrations), their purpose (improving visibility in performance dashboards), and includes a complete test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/sentry-performance-integrations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ntindle
Copy link
Member

ntindle commented Feb 4, 2026

@claude update this to follow the pr template

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@autogpt_platform/backend/backend/util/metrics.py`:
- Around line 41-44: The sentry-sdk extras in pyproject.toml are missing
"httpx", which prevents HttpxIntegration from working; update the sentry-sdk
dependency entry to include "httpx" in its extras list (so it contains
"anthropic", "fastapi", "httpx", "launchdarkly", "openai", "sqlalchemy") to
ensure HttpxIntegration used in metrics.py (HttpxIntegration) is properly
enabled.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c1aa684 and 9c41512.

📒 Files selected for processing (1)
  • autogpt_platform/backend/backend/util/metrics.py
🧰 Additional context used
📓 Path-based instructions (4)
autogpt_platform/backend/**/*.py

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

autogpt_platform/backend/**/*.py: Use Python 3.11 (required; managed by Poetry via pyproject.toml) for backend development
Always run 'poetry run format' (Black + isort) before linting in backend development
Always run 'poetry run lint' (ruff) after formatting in backend development

Files:

  • autogpt_platform/backend/backend/util/metrics.py
autogpt_platform/backend/**/*.{py,txt}

📄 CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use poetry run prefix for all Python commands, including testing, linting, formatting, and migrations

Files:

  • autogpt_platform/backend/backend/util/metrics.py
autogpt_platform/backend/backend/**/*.py

📄 CodeRabbit inference engine (autogpt_platform/backend/CLAUDE.md)

Use Prisma ORM for database operations in PostgreSQL with pgvector for embeddings

Files:

  • autogpt_platform/backend/backend/util/metrics.py
autogpt_platform/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Format Python code with poetry run format

Files:

  • autogpt_platform/backend/backend/util/metrics.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: types
  • GitHub Check: Seer Code Review
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: Check PR Status
🔇 Additional comments (1)
autogpt_platform/backend/backend/util/metrics.py (1)

9-10: LGTM for the added Sentry integration imports.

They’re used below and look consistent with the intended integrations.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines 41 to 44
AsyncioIntegration(),
FastApiIntegration(), # Traces FastAPI requests with detailed spans
HttpxIntegration(), # Traces outgoing HTTP calls (OpenAI, external APIs)
LoggingIntegration(sentry_logs_level=logging.INFO),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check sentry-sdk and httpx in project configuration files
echo "=== sentry-sdk in pyproject.toml ==="
rg -A 2 -B 2 "sentry-sdk" pyproject.toml

echo -e "\n=== httpx in pyproject.toml ==="
rg -A 2 -B 2 "httpx" pyproject.toml

echo -e "\n=== sentry-sdk version in poetry.lock ==="
rg -A 5 'name = "sentry-sdk"' poetry.lock | head -20

echo -e "\n=== httpx version in poetry.lock ==="
rg -A 5 'name = "httpx"' poetry.lock | head -20

Repository: Significant-Gravitas/AutoGPT

Length of output: 453


🏁 Script executed:

#!/bin/bash
# Find pyproject.toml and poetry.lock files
echo "=== Locating pyproject.toml ==="
find . -name "pyproject.toml" -type f 2>/dev/null

echo -e "\n=== Locating poetry.lock ==="
find . -name "poetry.lock" -type f 2>/dev/null

Repository: Significant-Gravitas/AutoGPT

Length of output: 512


🏁 Script executed:

#!/bin/bash
cd autogpt_platform/backend

echo "=== sentry-sdk in pyproject.toml ==="
rg -A 2 -B 2 "sentry-sdk" pyproject.toml

echo -e "\n=== httpx in pyproject.toml ==="
rg -A 2 -B 2 "httpx" pyproject.toml

echo -e "\n=== sentry-sdk version in poetry.lock ==="
rg -A 5 'name = "sentry-sdk"' poetry.lock | head -20

echo -e "\n=== httpx version in poetry.lock ==="
rg -A 5 'name = "httpx"' poetry.lock | head -20

Repository: Significant-Gravitas/AutoGPT

Length of output: 824


🏁 Script executed:

#!/bin/bash
# Check the actual integrations being imported in metrics.py
echo "=== Imports in metrics.py ==="
cd autogpt_platform/backend
head -50 backend/util/metrics.py | rg -A 20 "import\|from"

Repository: Significant-Gravitas/AutoGPT

Length of output: 101


🌐 Web query:

sentry-sdk 2.44.0 FastApiIntegration HttpxIntegration availability

💡 Result:

In sentry-sdk 2.44.0 (released Nov 11, 2025), both integrations are available:

  • FastAPI: from sentry_sdk.integrations.fastapi import FastApiIntegration (installable via the fastapi extra) [1][2][3]
  • httpx: from sentry_sdk.integrations.httpx import HttpxIntegration (installable via the httpx extra; also used for automatic outgoing HTTP tracing/headers when enabled) [2][4][5]

Install examples:

  • pip install "sentry-sdk[fastapi]==2.44.0" [2]
  • pip install "sentry-sdk[httpx]==2.44.0" [2]

Sources: [1] https://github.com/getsentry/sentry-python/releases (2.44.0), [2] https://pypi.org/project/sentry-sdk/ (extras list includes fastapi, httpx), [3] https://gitlab.donnees.incubateur.anct.gouv.fr/infrastructure/insitu/-/merge_requests/1374 (FastApiIntegration import snippet), [4] https://www.mail-archive.com/[email protected]/msg22390.html (shows __all__ = ["HttpxIntegration"] and class), [5] https://docs.sentry.io/platforms/python/tracing/configure-sampling__v3.x (mentions httpx auto-instrumentation/headers).


Add httpx to sentry-sdk extras in pyproject.toml.

sentry-sdk 2.44.0 supports both FastApiIntegration and HttpxIntegration, and the fastapi extra is installed. However, the httpx extra is missing from the sentry-sdk extras list. To ensure HttpxIntegration functions properly, update the sentry-sdk dependency to include httpx in its extras:

sentry-sdk = {extras = ["anthropic", "fastapi", "httpx", "launchdarkly", "openai", "sqlalchemy"], version = "^2.44.0"}
🤖 Prompt for AI Agents
In `@autogpt_platform/backend/backend/util/metrics.py` around lines 41 - 44, The
sentry-sdk extras in pyproject.toml are missing "httpx", which prevents
HttpxIntegration from working; update the sentry-sdk dependency entry to include
"httpx" in its extras list (so it contains "anthropic", "fastapi", "httpx",
"launchdarkly", "openai", "sqlalchemy") to ensure HttpxIntegration used in
metrics.py (HttpxIntegration) is properly enabled.

@claude
Copy link
Contributor

claude bot commented Feb 4, 2026

Claude finished @ntindle's task in 51s —— View job


Updated PR to follow template

  • Find and read the PR template
  • Read the current PR changes for context
  • Update the PR description to follow the template

Updated the PR description to match .github/PULL_REQUEST_TEMPLATE.md. The new description includes the standard Changes 🏗️ section with the list of changes, and the Checklist 📋 section with the code changes and configuration changes checklists filled in appropriately.

@ntindle ntindle closed this Feb 5, 2026
@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to ✅ Done in AutoGPT development kanban Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/backend AutoGPT Platform - Back end size/s

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants