feat(backend): Add Sentry error tracking integration#91
Merged
DevanshuNEU merged 11 commits intoDec 12, 2025
Merged
Conversation
FEATURES: - Sentry SDK integration with FastAPI - Automatic error capture with full stack traces - User context attached to errors (user_id, email) - Performance monitoring (10% sample in production) - Smart filtering (ignores health checks, bot paths) IMPLEMENTATION: - services/sentry.py: init_sentry(), set_user_context(), capture_exception() - main.py: Initialize Sentry before other imports - middleware/auth.py: Set user context after authentication CONFIGURATION: - SENTRY_DSN: Your Sentry project DSN - ENVIRONMENT: development/staging/production Sentry is optional - app works fine without SENTRY_DSN set. Closes OpenCodeIntel#54
|
@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel. A member of the Team first needs to authorize it. |
…andler ENHANCEMENTS: - Generic 500 exception handler captures all unhandled errors - Operation context tagging (indexing, search) - Search errors now captured with query context - track_background_task decorator for async jobs - sentry_operation context manager for scoped tracking NEW HELPERS: - set_operation_context(): Tag current operation - capture_http_exception(): For custom exception handlers - track_background_task(): Decorator for async functions All 49 tests passing.
FEATURES:
- Structured logging (JSON in prod, pretty in dev)
- OperationContext manager for scoped context
- trace_operation() for Sentry spans
- track_performance() decorator
- Simple metrics counters
USAGE:
from services.observability import get_logger, OperationContext, metrics
logger = get_logger('indexer')
with OperationContext(operation='indexing', repo_id='abc'):
logger.info('Processing file', context={'file': 'main.py'})
metrics.increment('files_processed')
Part of OpenCodeIntel#54 - comprehensive observability
…Intel#54) NEW: backend/services/observability.py - StructuredLogger: JSON logs (prod) / Pretty logs (dev) - operation_context: Context manager for operation tracking - track_performance: Decorator for Sentry spans - Metrics: Simple counters/gauges/histograms - Breadcrumbs: Debug trail for errors - capture_exception/capture_message: Manual error capture UPDATED: backend/services/sentry.py - Kept init_sentry() and set_user_context() - Re-exports observability functions for convenience - Cleaner separation of concerns Usage: from services.observability import get_logger, operation_context logger = get_logger('indexer') with operation_context('indexing', repo_id='abc') as ctx: logger.info('Starting', files=100) ctx.set_extra('functions', 340)
- Cleaner StructuredLogger with JSON/Pretty formatters - Simplified trace_operation context manager - Added track_performance decorator for async/sync functions - Simple Metrics class for counters and timings - Better Sentry integration with filtering Updates OpenCodeIntel#54
- Cleaner StructuredLogger with JSON (prod) / pretty (dev) output - Simplified Sentry helpers: set_operation_context, add_breadcrumb, capture_exception - track_time context manager for performance spans - trace_operation decorator for function-level tracing - Simple in-memory Metrics class for counters and timings - Better documentation with usage examples
…CodeIntel#54) - Replace all print() with structured logger calls - Add trace_operation and track_time for performance spans - Add breadcrumbs for debugging flow - Capture exceptions with context (repo_id, operation) - Add metrics: indexing_completed, search_requests, search_latency_ms
…er (OpenCodeIntel#54) - search_enhancer: Add structured logging for query expansion errors - dependency_analyzer: Replace all print() with structured logger - Add metrics for dependency_graphs_built - Capture exceptions with context
…l#54) - cache.py: Structured logging + cache hit/miss/error metrics - repo_manager.py: Logging for repo sync and clone operations - supabase_service.py: DB operation logging Added metrics: - cache_hits, cache_misses, cache_errors - repos_cloned
- playground.py: Structured logging for demo repo loading - analysis.py: Logging for dependency graph and style analysis - repos.py: Logging for indexing operations + WebSocket error capture All print() statements replaced with structured logger calls.
…deIntel#54) - style_analyzer.py: Logging for style analysis operations - performance_metrics.py: Logging for metrics initialization - indexer_optimized.py: Full logging for incremental indexing + error capture All print() statements replaced with structured logger calls. Total: ~50 print statements converted to structured logs.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Sentry error tracking for production visibility. No more flying blind when things break.
Problem
Currently zero visibility into production errors:
Solution
Integrated Sentry SDK with FastAPI for comprehensive error tracking.
Features
Files Changed
backend/services/sentry.pybackend/main.pybackend/middleware/auth.pybackend/requirements.txt.env.examplebackend/.env.exampleConfiguration
Sentry is optional - if SENTRY_DSN is not set, error tracking is simply disabled.
Usage
Errors are captured automatically. For manual capture:
Testing
What You'll See in Sentry
Closes #54