How to Set Up Application Monitoring with Sentry: Complete Guide | Dev Tool Rank

How to Set Up Application Monitoring with Sentry: Complete Guide

Tutorial ยท 5 min read ๐Ÿ”„ Affiliate Links

๐Ÿ” 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

Your app threw 4,000 exceptions last night. Nobody noticed until a customer emailed. That gap โ€” between something breaking and someone knowing about it โ€” is the entire reason error tracking exists, and it's the gap Sentry is built to close.

This guide walks through a real Sentry setup: installing the SDK, wiring up source maps so stack traces are readable, turning on performance tracing without blowing your quota, and configuring alerts that actually reach a human. I'll also show the pricing, the parts of Sentry that annoy me, and when a different tool makes more sense.

Everything below is based on the current Sentry SDKs (v8+ for JavaScript, v2+ for Python). If you're on an older version, a few of the handler APIs differ โ€” I'll flag those.


What Sentry Actually Does

Sentry started as an error tracker and has grown into something closer to a full observability platform. The core product is still exception monitoring, but there are five pieces you'll likely use:

Error tracking. Exceptions from your backend, frontend, mobile apps, and even background workers, grouped into issues with full stack traces, breadcrumbs (the sequence of events leading up to the error), and context about the request, user, and release.

Performance monitoring. Distributed tracing via OpenTelemetry-compatible spans. You get p50/p75/p95 latency for your endpoints, slow database queries, and the ability to see which span in a transaction ate the most time.

Session Replay. A DOM-level recording of what the user did before an error fired. It's the single most useful debugging feature Sentry has shipped โ€” you can watch someone rage-click a broken button instead of guessing.

Cron and uptime monitoring. Heartbeat checks for scheduled jobs and synthetic uptime checks. Less well known, genuinely handy if you run background workers.

Alerts and integrations. Issue alerts, metric alerts, and routing to Slack, PagerDuty, Discord, GitHub, or a webhook.

It supports basically every language you'd care about: JavaScript/TypeScript, Python, Ruby, PHP, Go, Java, Kotlin, Swift, Rust, .NET, Elixir, and more.


Sentry Pricing Compared

Sentry moved to usage-based billing, which means the headline price is a floor, not a ceiling. Here's roughly what the plans look like as of writing โ€” verify on the pricing page, because these numbers shift.

PlanPrice (annual billing)Errors includedSpans includedReplays includedNotable limits
DeveloperFree5,000/mo10M/mo50/mo1 user, 30-day retention, community support
Team~$26/mo50,000/mo5M/mo500/moUnlimited users, 90-day retention, Slack alerts
Business~$80/mo50,000/mo + pay-as-you-go5M/mo + PAYG500/mo + PAYGSSO, custom dashboards, 90-day retention
EnterpriseCustomNegotiatedNegotiatedNegotiatedSAML SSO, HIPAA/BAA, data residency, dedicated support

The important detail: on Team and Business, you can exceed the included volume and pay per-unit, or set hard rate limits per project. Spike protection is on by default and will throttle a runaway error loop before it costs you $400 overnight. Turn it on, keep it on.

Check Sentry Pricing ->


Step 1: Create a Project and Grab Your DSN

Sign up, create an organization, then create a project. Pick your platform โ€” Sentry uses this to pre-fill the setup snippet, so it matters less than you'd think. You can change it later.

Every project gets a DSN (Data Source Name), a URL that looks like https://[email protected]/789012. That's the credential your SDK uses to ship events. Treat it as semi-public: it's fine in a frontend bundle, but don't commit it to a public repo where scrapers will find it and spam your quota. Rotate the client key if that happens.

Store the DSN in an environment variable. Always.

SENTRY_DSN=https://[email protected]/789012


Step 2: Install the SDK (Node/Express)

npm install @sentry/node

Initialize Sentry before you import anything else in your entry file. The SDK patches modules at load time, and if Express loads first, you lose automatic instrumentation.

// server.js

const Sentry = require("@sentry/node");

const express = require("express");

Sentry.init({

dsn: process.env.SENTRY_DSN,

environment: process.env.NODE_ENV || "development",

release: process.env.GIT_SHA,

tracesSampleRate: 0.1,

sendDefaultPii: false,

});

const app = express();

app.get("/api/orders/:id", async (req, res) => {

const order = await db.orders.find(req.params.id);

if (!order) {

return res.status(404).json({ error: "not found" });

}

res.json(order);

});

// Register AFTER all routes and middleware

Sentry.setupExpressErrorHandler(app);

app.listen(3000);

That setupExpressErrorHandler line is the v8 API. On older SDKs you'll see Sentry.Handlers.requestHandler() and Sentry.Handlers.errorHandler() โ€” if you're copying a Stack Overflow answer from 2022 and nothing captures, that's why.

For errors you catch yourself, report them explicitly:

try {

await chargeCard(order);

} catch (err) {

Sentry.captureException(err, {

tags: { payment_provider: "stripe" },

user: { id: req.user.id },

});

throw err;

}

Tags are indexed and searchable. Context is not. Put anything you'll want to filter by in tags, and everything else in extra or contexts.


Step 3: Install the SDK (Python)

pip install --upgrade sentry-sdk

# main.py

import os

import sentry_sdk

from sentry_sdk.integrations.flask import FlaskIntegration

sentry_sdk.init(

dsn=os.environ["SENTRY_DSN"],

environment=os.getenv("ENV", "development"),

release=os.getenv("GIT_SHA"),

traces_sample_rate=0.1,

send_default_pii=False,

integrations=[FlaskIntegration()],

)

The Python SDK auto-detects most frameworks, so the explicit integration list is often optional. Django, Flask, FastAPI, Celery, and SQLAlchemy all get instrumented automatically โ€” which is convenient and also means your Celery workers will start reporting errors you didn't know existed. That first week is humbling.


Step 4: Frontend Setup and Source Maps

npm install @sentry/react

// main.jsx

import * as Sentry from "@sentry/react";

Sentry.init({

dsn: import.meta.env.VITE_SENTRY_DSN,

environment: import.meta.env.MODE,

integrations: [

Sentry.browserTracingIntegration(),

Sentry.replayIntegration({ maskAllText: true, blockAllMedia: true }),

],

tracesSampleRate: 0.1,

replaysSessionSampleRate: 0.01,

replaysOnErrorSampleRate: 1.0,

});

Now the part everyone skips and then regrets: source maps. Without them

๐Ÿ” Want the best deal? Check current prices and availability.

Compare Prices โ†’
D

Dev Tool Rank Editorial Team

We're a team of tech enthusiasts who test and review tools so you don't have to. Our reviews are independent โ€” we only recommend what we'd actually use ourselves.