What to Track
Practical guidance on what metrics to track, how to explore them, and when to set alerts.
You've set up Sentry Metrics. Now what? This guide covers the high-value metric patterns that give you visibility into application health and how to drill into traces when something looks off.
Sentry supports three metric types:
| Type | Method | Use For |
|---|---|---|
| Counter | Sentry.metrics.count() | Events that happen (orders, clicks, errors) |
| Gauge | Sentry.metrics.gauge() | Current state (queue depth, connections) |
| Distribution | Sentry.metrics.distribution() | Values that vary (latency, sizes, amounts) |
Every metric is trace-connected. When a metric spikes, click into samples to see the exact trace that produced it.
Sentry.metrics.count("checkout.failed", 1, {
attributes: {
user_tier: "premium",
failure_reason: "payment_declined",
},
});
Start with these five metrics and you'll spot issues before they become problems.
Track discrete events that matter to the business. These become your KPIs.
Sentry.metrics.count("checkout.completed", 1, {
attributes: { user_tier: "premium", payment_method: "card" },
});
Sentry.metrics.count("checkout.failed", 1, {
attributes: { user_tier: "premium", failure_reason: "payment_declined" },
});
Explore in Sentry:
- Go to Explore > Metrics
- Select
checkout.failed, set Aggregate tosum - Group by
failure_reason - Click Samples to see individual events and their traces
Track success and failure of critical operations.
Sentry.metrics.count("email.sent", 1, {
attributes: { email_type: "welcome", provider: "sendgrid" },
});
Sentry.metrics.count("email.failed", 1, {
attributes: { email_type: "welcome", error: "rate_limited" },
});
Sentry.metrics.count("job.processed", 1, {
attributes: { job_type: "invoice-generation", queue: "billing" },
});
Query in Explore > Metrics: Add both email.sent and email.failed, group by email_type, compare the ratio.
Track the current state of pools, queues, and connections. Call these periodically (e.g., every 30 seconds).
Sentry.metrics.gauge("queue.depth", await queue.size(), {
attributes: { queue_name: "notifications" },
});
Sentry.metrics.gauge("pool.connections_active", pool.activeConnections, {
attributes: { pool_name: "postgres-primary" },
});
Query in Explore > Metrics: View max(queue.depth) over time to spot backlogs.
Track values that vary and need percentile analysis. Tip: averages can hide outliers, use p90/p95/p99 instead.
Sentry.metrics.distribution("api.latency", responseTimeMs, {
unit: "millisecond",
attributes: { endpoint: "/api/orders", method: "POST" },
});
Sentry.metrics.distribution("db.query_time", queryDurationMs, {
unit: "millisecond",
attributes: { table: "orders", operation: "select" },
});
Query in Explore > Metrics: View p95(api.latency) grouped by endpoint to find slow routes.
Track amounts, sizes, and quantities for analysis.
Sentry.metrics.distribution("order.amount", order.totalUsd, {
unit: "usd",
attributes: { user_tier: "premium", region: "us-west" },
});
Sentry.metrics.distribution("upload.size", fileSizeBytes, {
unit: "byte",
attributes: { file_type: "image", source: "profile-update" },
});
Query in Explore > Metrics: View avg(order.amount) grouped by region to compare regional performance.
Alerts and dashboard widgets for Metrics are coming soon.
You'll soon be able to:
- Create alert rules based on metric queries
- Add metric visualizations to dashboards
- Set up notifications when metrics cross thresholds
- Save common queries for quick access
| Category | Type | Method | Example Attributes |
|---|---|---|---|
| Business events | Counter | count() | user_tier, payment_method, failure_reason |
| Application health | Counter | count() | email_type, provider, job_type, queue |
| Resource utilization | Gauge | gauge() | queue_name, pool_name |
| Latency/performance | Distribution | distribution() | endpoint, method, table, operation |
| Business values | Distribution | distribution() | user_tier, region, file_type |
| Signal | Best For | Example Question |
|---|---|---|
| Metrics | Aggregated counts, rates, percentiles | "How many checkouts failed this hour?" |
| Traces | Request flow, latency breakdown | "Why was this specific request slow?" |
| Logs | Detailed context, debugging | "What happened right before this error?" |
All three are trace-connected. Start wherever makes sense and navigate to the others.
Explore the Metrics product walkthrough guides to learn more about the Sentry interface and discover additional tips.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").