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:

TypeMethodUse For
CounterSentry.metrics.count()Events that happen (orders, clicks, errors)
GaugeSentry.metrics.gauge()Current state (queue depth, connections)
DistributionSentry.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.

Copied
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.

Copied
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:

  1. Go to Explore > Metrics
  2. Select checkout.failed, set Aggregate to sum
  3. Group by failure_reason
  4. Click Samples to see individual events and their traces

Track success and failure of critical operations.

Copied
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).

Copied
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.

Copied
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.

Copied
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.

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

CategoryTypeMethodExample Attributes
Business eventsCountercount()user_tier, payment_method, failure_reason
Application healthCountercount()email_type, provider, job_type, queue
Resource utilizationGaugegauge()queue_name, pool_name
Latency/performanceDistributiondistribution()endpoint, method, table, operation
Business valuesDistributiondistribution()user_tier, region, file_type

SignalBest ForExample Question
MetricsAggregated counts, rates, percentiles"How many checkouts failed this hour?"
TracesRequest flow, latency breakdown"Why was this specific request slow?"
LogsDetailed 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.

Was this helpful?
Help improve this content
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").