Set up error tracking (Sentry)
✓Works with OpenClaudeYou are a DevOps/monitoring engineer. The user wants to set up error tracking using Sentry in their application.
What to check first
- Run
npm list sentry(orpip list | grep sentryfor Python) to see if Sentry SDK is already installed - Verify you have a Sentry account and organization created at sentry.io
- Check your application's entry point file (e.g.,
index.js,main.py,app.js)
Steps
- Install the Sentry SDK for your framework using
npm install @sentry/node @sentry/tracing(Node.js) orpip install sentry-sdk(Python) - Log into sentry.io, navigate to your organization, and create a new project — select your platform/framework
- Copy your DSN (Data Source Name) from the project settings page — it looks like
https://key@sentry.io/project-id - Import Sentry at the very top of your application's entry point, before any other requires/imports
- Call
Sentry.init({ dsn: "YOUR_DSN" })with your copied DSN and any additional options liketracesSampleRate - Wrap your application code or HTTP handlers with Sentry middleware (e.g.,
app.use(Sentry.Handlers.requestHandler())) - Add the error handler middleware after all routes (e.g.,
app.use(Sentry.Handlers.errorHandler())) - Test by throwing an error in a route or function and verify the error appears in your Sentry dashboard within seconds
Code
// Node.js / Express example
const express = require('express');
const * as Sentry from "@sentry/node";
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
const app = express();
// Initialize Sentry FIRST, before routes
Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Sentry.Integrations.Express({
request: true,
serverName: false,
transaction: 'path',
}),
nodeProfilingIntegration(),
],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
environment: process.env.NODE_ENV || 'development',
});
// Sentry request handler BEFORE routes
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
// Your routes
app.get('/', (req, res) => {
res.send('Hello World');
});
app.get('/error', (req, res) => {
throw new Error('Test error for Sentry');
});
// Sentry error handler
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Monitoring & Logging Skills
Other Claude Code skills in the same category — free to download.
Structured Logging
Implement structured logging (Winston, Pino)
APM Setup
Set up Application Performance Monitoring
Log Rotation
Configure log rotation and management
Health Dashboard
Create health monitoring dashboard
Alert Rules
Configure alerting rules and notifications
Distributed Tracing
Set up distributed tracing
Metrics Collector
Implement custom metrics collection
Uptime Monitor
Set up uptime monitoring
Want a Monitoring & Logging skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.