Sentry Error Tracking
Sentry is a real-time error tracking and performance monitoring platform that helps you identify, diagnose, and fix issues in production. Bindu includes built-in Sentry integration to provide comprehensive observability for your AI agents.Why Use Sentry?
1. Real-Time Error Tracking
Sentry captures and reports errors as they happen:- Automatic error capture - Exceptions are caught and reported automatically
- Stack traces - Full context of where and why errors occurred
- Breadcrumbs - Trail of events leading up to the error
- User context - Know which users are affected
- Environment context - Server, release, and deployment information
2. Performance Monitoring
Track application performance and identify bottlenecks:- Transaction tracing - Monitor request/response times
- Database query performance - Identify slow queries
- External API calls - Track third-party service latency
- Custom instrumentation - Measure specific operations
- Performance trends - Historical performance data
3. Release Health Tracking
Monitor the health of your deployments:- Crash-free sessions - Track stability across releases
- Adoption rate - See how quickly users upgrade
- Issue regression - Detect when bugs reappear
- Deploy markers - Correlate issues with deployments
4. Intelligent Alerting
Get notified when things go wrong:- Smart grouping - Similar errors grouped together
- Alert rules - Custom thresholds and conditions
- Integration - Slack, PagerDuty, email, webhooks
- Noise reduction - Filter out expected errors
5. Deep Integration
Binduβs Sentry integration captures:- Starlette/FastAPI - HTTP request errors and performance
- SQLAlchemy - Database query errors and slow queries
- Redis - Cache and queue operation errors
- Loguru - Application logs as breadcrumbs
- Asyncio - Async task errors and context
6. Privacy & Compliance
Sentry respects user privacy:- PII scrubbing - Automatically filter sensitive data
- Custom filters - Define what data to exclude
- On-premise option - Self-hosted Sentry for complete control
- GDPR compliant - Meets European privacy standards
When to Use Sentry
β Use Sentry when:- Running in production environments
- Need to track errors across multiple instances
- Want performance monitoring and optimization
- Require alerting for critical errors
- Building enterprise applications
- Need audit trails and compliance
- Want to improve agent reliability
- Only developing locally (use console logs)
- Cost is a major constraint (Sentry has free tier but limits)
- You already have a comprehensive monitoring solution
Architecture
Binduβs Sentry integration works seamlessly with your application:How It Works
- Automatic Instrumentation: Sentry SDK hooks into Starlette, SQLAlchemy, Redis, etc.
- Error Capture: Exceptions are caught and enriched with context
- Transmission: Events sent to Sentry (batched for efficiency)
- Processing: Sentry groups, analyzes, and stores events
- Alerting: Notifications sent based on alert rules
- Analysis: View errors, performance, and trends in Sentry UI
Configuration
Sentry can be configured in two ways: via environment variables or directly in your agent code.Option 1: In-Code Configuration (Recommended)
Configure Sentry directly in yourbindufy() config:
- β No environment variables needed
- β Configuration lives with your code
- β Easy to version control
- β Perfect for packages and libraries
- β Different configs for different agents
Option 2: Environment Variables
Configure via.env file or environment:
- β Separate config from code
- β Easy to change without code changes
- β Good for deployment pipelines
Configuration Priority
If both are provided, in-code config takes precedence:- In-code config (
config["sentry"]) - Highest priority - Environment variables (
SENTRY__*) - Fallback
Configuration Options
What Gets Tracked
β All HTTP Endpoints (Automatic)
TheStarletteIntegration automatically instruments all Starlette routes:
1. A2A Protocol Endpoint
POST /- Main agent communication endpoint- Captures errors and performance
2. Agent Card Endpoint
GET /.well-known/agent.json- Agent discovery- Tracks endpoint availability
3. DID Endpoints
GET/POST /did/resolve- DID resolution- Monitors identity operations
4. Skills Endpoints
GET /agent/skills- List all skillsGET /agent/skills/{skill_id}- Get skill detailsGET /agent/skills/{skill_id}/documentation- Get skill docs
5. Payment Session Endpoints (X402)
POST /api/start-payment-session- Start paymentGET /payment-capture- Payment capture pageGET /api/payment-status/{session_id}- Payment status
6. Static/UI Endpoints
GET /docs- Chat UIGET /favicon.ico- FaviconGET /static/*- Static files (CSS/JS)
β Database Operations (SQLAlchemy)
When using PostgreSQL storage: Captured automatically:- SQL queries (parameterized, no sensitive data)
- Query execution time
- Database connection errors
- Slow query warnings
- Transaction failures
β Redis Operations
When using Redis scheduler: Captured automatically:- Redis commands (LPUSH, BRPOP, etc.)
- Command execution time
- Connection errors
- Timeout errors
- Queue operations
β Logging Events
All error-level logs are sent to Sentry:- Error-level logs β Sentry events
- All logs β Breadcrumbs (context trail)
β Async Operations
Async task errors are captured: Captured automatically:- Unhandled exceptions in async tasks
- Coroutine context
- Task stack traces
β Whatβs NOT Captured (Filtered)
Health Check Endpoints:/healthz/health/metrics/favicon.ico
authorizationheadersx-api-keyheaderscookieheaderspasswordfieldstokenfieldssecretfieldsapi_keyfieldsprivate_keyfields
Getting Started
1. Create Sentry Account
Sign up for a free Sentry account:- Go to sentry.io
- Create an account (free tier available)
- Create a new project (select βPythonβ as platform)
2. Get Your DSN
From your Sentry project settings:- Navigate to Settings β Projects β [Your Project]
- Go to Client Keys (DSN)
- Copy the DSN URL
3. Configure Bindu
Add to your agent config:4. Run Your Agent
5. Test Error Tracking
Trigger a test error:Features
Automatic Error Capture
All unhandled exceptions are automatically captured:Manual Error Capture
Capture specific errors with additional context:Breadcrumbs
Add breadcrumbs for debugging context:User Context
Associate errors with specific users:Custom Context
Add custom context to errors:Performance Monitoring
Track custom operations:Message Capture
Send informational messages to Sentry:Best Practices
1. Environment Configuration
Use different environments for different deployments:2. Release Tracking
Set release version for deployment tracking:3. Sample Rates
Adjust sampling based on traffic: Low traffic (< 1000 requests/day):4. PII Scrubbing
Never send sensitive data to Sentry:- Passwords
- API keys
- Tokens
- Credit card numbers
- Social security numbers
5. Filter Noise
Ignore expected errors:6. Alert Configuration
Set up alerts in Sentry UI:- Critical errors: Immediate notification (Slack, PagerDuty)
- Performance degradation: Daily digest
- New issues: Weekly summary
7. Context Enrichment
Always add context to manual captures:Monitoring & Dashboards
Sentry Dashboard
Key metrics to monitor:- Error Rate: Errors per hour/day
- Crash-Free Sessions: % of sessions without crashes
- Response Time: p50, p95, p99 latencies
- Throughput: Requests per second
- Top Errors: Most frequent errors
- Slow Transactions: Slowest operations
Custom Dashboards
Create custom dashboards for:- Task processing performance
- LLM API latency
- Database query performance
- Redis operation metrics
- User-specific errors
Alerts
Set up alerts for:- Error rate > threshold
- New error types
- Performance degradation
- Specific error patterns
- Release health issues
Troubleshooting
Sentry Not Initializing
Symptom: No errors appearing in Sentry Solutions:- Check
SENTRY__ENABLED=true - Verify DSN is correct
- Check network connectivity to Sentry
- Look for initialization errors in logs
Too Many Events
Symptom: Hitting Sentry quota limits Solutions:- Reduce
SENTRY__PROFILES_SAMPLE_RATE - Filter out noisy transactions
- Ignore expected errors
- Upgrade Sentry plan
Missing Context
Symptom: Errors lack debugging information Solutions:- Add breadcrumbs before operations
- Set user context
- Add custom context
- Increase
SENTRY__MAX_BREADCRUMBS
Performance Impact
Symptom: Sentry slowing down application Solutions:- Reduce sampling rates
- Disable profiling
- Filter transactions
- Use async transport (default)
Security Considerations
1. DSN Protection
The DSN is public but rate-limited:- Donβt commit DSN to public repos (use environment variables)
- Rotate DSN if exposed
- Use Sentryβs rate limiting
2. PII Scrubbing
Always disable PII in production:3. Data Retention
Configure data retention in Sentry:- Default: 90 days
- Can be reduced for compliance
- Can be extended with paid plans
4. Self-Hosted Option
For maximum control, use self-hosted Sentry:Cost Optimization
Free Tier
Sentryβs free tier includes:- 5,000 errors/month
- 10,000 performance units/month
- 1 project
- 30-day data retention
Optimization Tips
- Sample transactions: Use low
PROFILES_SAMPLE_RATE - Filter noise: Exclude health checks, metrics
- Ignore errors: Filter expected errors
- Use environments: Separate dev/staging/prod projects
- Monitor quota: Set up quota alerts
Paid Plans
Consider paid plans for:- Higher error volume
- More projects
- Longer retention
- Advanced features (SAML SSO, etc.)
Comparison with Alternatives
| Feature | Sentry | Rollbar | Bugsnag | Datadog |
|---|---|---|---|---|
| Error tracking | β Excellent | β Good | β Good | β Good |
| Performance | β Built-in | β Limited | β Limited | β Excellent |
| Free tier | β 5K errors | β 5K errors | β 7K errors | β οΈ Trial only |
| Self-hosted | β Yes | β No | β No | β No |
| Python support | β Excellent | β Good | β Good | β Excellent |
| Integrations | β Extensive | β οΈ Moderate | β οΈ Moderate | β Extensive |
| Best for | General use | Error tracking | Mobile apps | Full observability |
Conclusion
Sentry provides comprehensive error tracking and performance monitoring for Bindu agents. It offers:- β Real-time error tracking: Catch issues as they happen
- β Performance monitoring: Optimize agent response times
- β Release health: Track deployment stability
- β Deep integration: Starlette, SQLAlchemy, Redis, Loguru
- β Privacy-first: PII scrubbing and compliance
- β Free tier: Get started without cost
Next Steps: