Sentry Error Tracking
Configure Sentry for error monitoring and performance tracking.
Setupโ
1. Create Sentry Projectโ
- Go to sentry.io
- Create a new project for Node.js
- Copy the DSN
2. Configureโ
SENTRY_DSN=https://xxx@sentry.io/12345
SENTRY_TRACES_SAMPLE_RATE=0.1
SENTRY_ENVIRONMENT=production
3. Integrationโ
Sentry is automatically configured in the API when SENTRY_DSN is set. It captures:
- Unhandled exceptions
- HTTP 5xx responses
- Slow database queries
- Performance traces
Featuresโ
| Feature | Description |
|---|---|
| Error grouping | Similar errors grouped |
| Stack traces | Full stack traces with context |
| Breadcrumbs | Events leading to error |
| Performance | Transaction tracing |
| Release tracking | Errors by release version |
| Alerts | Email/Slack notifications |
Custom Error Contextโ
import * as Sentry from "@sentry/node";
Sentry.setUser({ id: userId, email: userEmail });
Sentry.setTag("tenant", tenantId);
Sentry.captureMessage("Custom event");
Source Mapsโ
Upload source maps for readable stack traces:
sentry-cli releases files $VERSION upload-sourcemaps ./dist
Related Pagesโ
- Error Handling Architecture โ error patterns
- Prometheus Metrics โ metrics monitoring
- Grafana Dashboards โ visualization