How to Set Up Application Monitoring with Sentry: Complete Guide
๐ Want the best deal? Check current prices and availability.
Compare Prices โWhen you buy through links on our site, we may earn a commission.
How to Set Up Application Monitoring with Sentry: Complete Guide
I've been building web applications for over a decade, and I've lost count of how many times I've spent hours tracking down a bug that only happened in production. You know the drill: a user reports something weird, you can't reproduce it locally, and you're left digging through generic server logs hoping for clues.
That's where Sentry comes in. It's hands-down the most widely used application monitoring and error tracking tool out there. And after using it across dozens of projects โ from simple React SPAs to complex Node.js backends โ I can tell you exactly how to set it up right, what it's actually good at, and where it might fall short.
This guide walks through the full setup process, covers the features that matter, and gives you the real talk on pricing. Let's get started.
What Is Sentry, Exactly?
Sentry is an open-source error tracking and performance monitoring platform. It captures unhandled exceptions, logs context around failures (stack traces, user data, breadcrumbs), and now includes performance monitoring to show you slow transactions and database queries.
It supports literally every major language and framework: JavaScript, Python, Ruby, PHP, Go, Rust, Java, .NET, and more. The SDKs are mature and maintained by Sentry's team.
Step-by-Step Sentry Setup
1. Create Your Sentry Account and Project
Head to sentry.io and sign up. You can start with a free tier that gives you 5,000 errors and 10,000 transactions per month โ enough for small side projects or early-stage apps.
Once logged in:
- Click Create Project in the sidebar
- Choose your framework (React, Next.js, Express, etc.)
- Give it a project name
- Copy the DSN string (it's your project's unique identifier)
Sentry will auto-generate a quick setup snippet tailored to your framework.
2. Install the Sentry SDK
For a JavaScript project, install the core SDK plus the framework-specific package:
npm install @sentry/react @sentry/tracing
For Node.js backends:
npm install @sentry/node @sentry/tracing
3. Initialize Sentry in Your Application
This is the most important step. Initialize Sentry as early as possible in your app's lifecycle โ before any other code runs.
For a React app:
import * as Sentry from "@sentry/react";
import { BrowserTracing } from "@sentry/tracing";
Sentry.init({
dsn: "https://[email protected]/450000",
integrations: [new BrowserTracing()],
tracesSampleRate: 0.2, // 20% of transactions captured for performance
environment: process.env.NODE_ENV,
release: "my-app@" + process.env.npm_package_version,
});
For Node.js / Express:
import * as Sentry from "@sentry/node";
import { ProfilingIntegration } from "@sentry/profiling-node";
Sentry.init({
dsn: "https://[email protected]/450000",
integrations: [new ProfilingIntegration()],
tracesSampleRate: 0.2,
environment: process.env.NODE_ENV,
release: "my-backend@" + process.env.npm_package_version,
});
Key parameters to set properly:
tracesSampleRate: start at 0.2 (20%). Increase to 1.0 only if you're on the paid plan and have budget.environment: separate dev, staging, and production. This saves you from debugging test errors.release: tie errors to a specific deployment. Makes regression hunting trivial.
4. Add Error Boundary (React-Specific)
If you're using React, wrap your app in Sentry's error boundary:
class App extends React.Component {
render() {
return (
}>
);
}
}
This catches all React render errors and sends them to Sentry without crashing the whole UI.
5. Set Up Performance Monitoring
For backend performance tracking, wrap your route handlers:
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler());
app.get("/api/users", async (req, res) => {
const transaction = Sentry.getCurrentHub().getScope().getTransaction();
const span = transaction?.startChild({ op: "db.query", description: "get_users" });
const users = await db.query("SELECT * FROM users");
span?.finish();
res.json(users);
});
app.use(Sentry.Handlers.errorHandler());
This gives you flame graphs showing where time is actually spent โ database queries vs. external API calls vs. your own logic.
Features That Actually Matter
Not all Sentry features are equally useful. Here's what I've found valuable in real projects:
Source Maps
Sentry automatically deobfuscates minified JavaScript. Upload your source maps via sentry-cli or the webpack plugin, and you'll see actual file names and line numbers instead of bundle.js:1:32432.
Without this, stack traces are basically garbage.
Breadcrumbs
Sentry logs a trail of events leading up to an error โ HTTP requests, console logs, user interactions, navigation events. When debugging, this is often more useful than the error itself.
Alerting and Issues
Sentry groups identical errors into "issues" with a priority score. You can set alert rules: "Alert me if this issue affects more than 10 users in an hour." No noise, just signal.
Performance Traces
The performance monitoring shows you the entire lifecycle of a request or page load. You can see which database query took 400ms, which API endpoint is slow, and how long JavaScript execution takes.
Pricing Comparison
Here's how Sentry stacks up against alternatives. Note: prices change, and this reflects public pricing as of mid-2025.
| Feature | Sentry (Free) | Sentry (Team - $26/user/mo) | Datadog APM (Pro - $31/host/mo) | Rollbar (Pro - $19/user/mo) |
|---|---|---|---|---|
| Error tracking | 5,000 events | 50,000 events | 1M log events | 15,000 events |
| Performance monitoring | 10,000 transactions | 100,000 transactions | Unlimited (per host) | N/A |
| Source maps | โ | โ | N/A | โ |
| Slack/email alerts | โ | โ | โ | โ |
| Custom dashboards | Limited | โ | โ | โ |
| Uptime monitoring | โ | โ | โ | โ |
| Official support | N/A | Phone + Slack |
The verdict on pricing: Sentry's free tier is generous for small projects. Their paid Team plan gets expensive fast if you have a large org. Datadog is pricier per host but includes metrics, logs, and APM in one platform. Rollbar is a simpler, cheaper alternative if you only need error tracking.
Pros and Cons
After years of using Sentry across production systems, here's my honest assessment.
Pros
- Best-in-class error grouping โ Sentry's algorithm for deduplicating errors is smarter than most competitors. You won't see 500 identical errors cluttering your dashboard.
- Rich context in errors โ User agent, device info, browser extensions, OS, breadcrumbs, and custom tags all come automatically.
- Performance + errors in one dashboard โ You don't need two separate tools to see what broke and why it's slow.
- Open source core โ You can self-host Sentry if you need to keep everything on your own infrastructure.
- Excellent SDKs โ The docs are clear, the APIs are consistent across languages, and they handle edge cases like async errors well.
Cons
- Alert noise can be high โ Out of the box, Sentry sends you alerts for every new error. Without tuning rules, you'll get overwhelmed.
- Pricing scales with volume โ If your app grows, the paid tiers can cost hundreds per month. Each additional user in your Sentry org costs $26/mo.
- Performance monitoring is basic โ It works, but it's not Datadog or New Relic level. You can't do advanced trace comparisons or set complex SLAs.
- UI overload โ The dashboard has a lot of knobs. The learning curve for setting up dashboards and filters is real.
- Self-hosting is a pain โ While possible, self-hosted Sentry requires significant operational overhead (PostgreSQL, Redis, Kafka, ClickHouse). It's not a weekend project.
Who Should Use Sentry?
Sentry fits best for:
- Startups and small teams who need one tool for errors + performance without a massive ops investment
- Web developers building with React, Next.js, Node.js, Python, or Ruby โ those SDKs are first-class
- Open source projects โ Sentry offers a free plan for open source maintainers
Sentry is not ideal for:
- Teams already using Datadog โ Datadog's APM is more powerful, and adding Sentry is another bill
- High-volume apps on a budget โ Processing 5M+ errors/month will be expensive
- Developers who only need logs โ Sentry is not a log aggregator. Use something like Better Stack or Papertrail instead.
Final Verdict
I've recommended Sentry to dozens of developers, and I'll keep doing so โ with caveats. For most small-to-medium web applications, Sentry is the best error tracking tool available right now. The free tier is genuinely useful, the SDKs are polished, and the combination of error tracking with basic performance monitoring covers the 80% case.
But here's where I draw the line: if you're already using Datadog or Grafana for observability, don't add Sentry. You'll pay for overlap.
If you need a single, easy-to-setup tool that catches errors in production and helps you find their root cause, go with Sentry. It's earned its spot in most every dev's toolbox.
FAQ
Is Sentry free?
Yes. The free plan includes 5,000 error events and 10,000 performance transactions per month. Enough for small projects, hobby apps, or evaluation.
How does Sentry differ from log monitoring?
Sentry captures errors and performance data with full context (stack traces, user info, breadcrumbs). Log monitoring (like Papertrail or Logstash) stores raw text logs. You can't do error grouping or get stack traces from log files.
Can I use Sentry for mobile apps?
Absolutely. Sentry has SDKs for iOS, Android, Flutter, React Native, and Unity. The setup is similar to the web SDK.
Does Sentry slow down my app?
The SDK runs asynchronously and adds minimal overhead (typically <5ms per event). The bigger impact is on the Sentry server side โ if you set tracesSampleRate to 1.0 on a busy app, you'll pay for it. Start low (0.1-0.2) and adjust.
What happens if Sentry's servers are down?
Sentry buffers events locally and retries. If the outage is short (minutes), you won't lose data. If it's longer, events may drop. Self-hosted Sentry avoids this but requires maintenance.
Can I self-host Sentry?
Yes. It's open source. But the infrastructure requirements are heavy: you need PostgreSQL, Redis, Kafka, and ClickHouse running properly. I wouldn't recommend it unless you have a dedicated DevOps person.
How do I set up Sentry with Next.js?
Next.js has a dedicated Sentry integration via @sentry/nextjs. It automatically handles server-side and client-side error tracking, and supports source maps for your API routes. Check the official Next.js setup docs.
๐ Want the best deal? Check current prices and availability.
Compare Prices โ