Skip to content

feat(backend): integrate Sentry SDK for production error tracking#847

Open
Nicks-19 wants to merge 2 commits into
imDarshanGK:mainfrom
Nicks-19:feat/add-sentry-integration
Open

feat(backend): integrate Sentry SDK for production error tracking#847
Nicks-19 wants to merge 2 commits into
imDarshanGK:mainfrom
Nicks-19:feat/add-sentry-integration

Conversation

@Nicks-19

@Nicks-19 Nicks-19 commented Jun 4, 2026

Copy link
Copy Markdown

Description

This PR integrates the Sentry SDK into the backend FastAPI application to enable comprehensive error tracking, performance profiling, and context tagging for production environments.

Closes #531

Changes

  1. Dependency updates: Added sentry-sdk>=2.0.0 to backend/requirements.txt.
  2. Configuration: Added sentry_environment (defaults to ENVIRONMENT or "production") and sentry_profiles_sample_rate to the FastAPI settings in backend/app/config.py.
  3. Initialization & Tags: Enhanced init_error_tracking() in backend/app/services/error_tracking.py to configure Sentry with dynamic environment and profiling options, alongside attaching metadata tags (app_name, ai_provider, ai_model, llm_enabled) and app settings context.
  4. App Integration: Updated FastAPI lifespan in backend/app/main.py to run the initializer, and modified the global exception handler to automatically capture all unhandled errors via sentry_sdk.capture_exception().
  5. Testing: Implemented comprehensive unit tests in backend/tests/test_error_tracking.py covering disabled states, configuration mapping, metadata tags verification, and capturing behavior in the global error handler.

Verification

  • All 402 tests pass successfully.
  • Verified that global exception handler captures errors using mock test clients with raise_server_exceptions=False.

@Nicks-19 Nicks-19 requested a review from imDarshanGK as a code owner June 4, 2026 17:16
@imDarshanGK

Copy link
Copy Markdown
Owner

@Nicks-19 Resolve conflicts

@Nicks-19

Copy link
Copy Markdown
Author

Hi @imDarshanGK
I have resolved the merge conflicts in backend/requirements.txt by merging the latest changes from main and keeping the dependencies clean.

Could you please approve the CI workflows and review the PR?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Sentry integration for production error tracking

2 participants