The Sentry Bun SDK is in Beta. Please help us improve the SDK by reporting issues or giving feedback.
Installation
Basic Setup
Initialize Sentry as early as possible in your main entry module:Bun.serve Integration
Monitor your Bun HTTP server:Error Tracking
Automatic Error Capture
Manual Error Capture
Performance Monitoring
Custom Spans
Nested Spans
Context & User Information
Set User Context
Add Custom Context
Breadcrumbs
Database Integration
Bun SQLite
HTTP Client Tracking
WebSocket Support
File System Operations
Cron Monitoring
Environment Variables
Configuration
Complete Configuration
Complete Configuration
Best Practices
Initialize Early
Call
Sentry.init() at the very beginning of your main module.Use Spans
Wrap important operations with spans to track performance.
Error Context
Add context and tags to make debugging easier.
Sample Rates
Adjust sample rates in production to control costs.
Bun-Specific Features
Bun.serve Performance
The Bun runtime is optimized for performance. Sentry adds minimal overhead:- Automatic request tracking
- Native async context propagation
- Fast error capture
Memory Usage
The SDK is optimized for Bun’s memory management:Common Patterns
- REST API
- File Uploads
Next Steps
Bun Documentation
Official Bun documentation
Performance
Deep dive into performance monitoring
Source Maps
Upload source maps for production
Deployment
Deploy Bun applications