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