Set Up

Learn how to set up Sentry's Metrics feature using our supported SDKs.

To set up Sentry Metrics, use the links below for supported SDKs. After it's been set up, you'll be able to send counters, gauges, and distributions from your code and view them in Sentry with direct links to related traces.

We're actively working on adding Metrics functionality to additional SDKs. Check out these GitHub issues for the latest updates:

If you don't see your platform listed above, please reach out to us on GitHub, Discord or contact us at feedback-metrics@sentry.io, we'll get it prioritized!

Use descriptive, dot-separated names that indicate the metric's purpose:

  • Good: checkout.failed, email.sent, queue.depth
  • Avoid: metric1, counter, x

Add attributes for any dimension you want to group or filter by:

Copied
Sentry.metrics.count("api.request", 1, {
  attributes: {
    endpoint: "/users",
    method: "GET",
    status: "200",
    region: "us-west",
  },
});

This allows you to query metrics like:

  • sum(api.request) grouped by endpoint
  • sum(api.request) where status:500
  • sum(api.request) grouped by region where method:POST

Always specify units for clarity:

  • Time: millisecond, seconds
  • Size: byte, kilobyte, megabyte

Add metrics at key decision points in your code:

  • Before/after critical operations: Track success and failure rates
  • At service boundaries: Monitor external API calls, database queries
  • Business logic: Capture important business events
  • Resource usage: Track queue depths, connection pools, cache sizes
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").