Error Monitoring — Tracking Errors with Sentry
DodaTech
Updated 2026-06-28
1 min read
In this tutorial, you will learn about Error Monitoring. We cover key concepts, practical examples, and best practices to help you master this topic.
Error monitoring tools like Sentry capture, aggregate, and alert on API errors, providing stack traces, request context, and trends to help teams fix issues before users are affected.
Sentry Integration
const Sentry = require("@sentry/node");
const { ProfilingIntegration } = require("@sentry/profiling-node");
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
tracesSampleRate: 1.0,
integrations: [new ProfilingIntegration()]
});
// Express integration
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
app.use(Sentry.Handlers.errorHandler());
Error Context
Add context to errors for better debugging:
app.use((req, res, next) => {
Sentry.setUser({ id: req.user?.id, email: req.user?.email });
Sentry.setTag("api_version", req.headers["accept-version"]);
Sentry.setExtra("request_body", req.body);
next();
});
Common Mistakes
- No error monitoring — Discovering errors through user reports.
- Over-alerting — Alerting on every 4xx error.
- No release tracking — Cannot correlate errors with deployments.
Practice Questions
- What is the purpose of error monitoring?
- How do you add request context to Sentry events?
- What types of errors should trigger alerts?
Challenge
Set up Sentry for an Express API. Configure request handlers, error handlers, custom context, release tracking, and alert rules for 5xx errors.
What's Next
In the final lesson, you will complete an error handling project.
← Previous
Error Logging — Structured Error Logging for APIs
Next →
Error Handling Project — Complete Error System
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro