Module sentry::metrics

source ·
Expand description

Utilities to track metrics in Sentry.

Metrics are numerical values that can track anything about your environment over time, from latency to error rates to user signups.

Metrics at Sentry come in different flavors, in order to help you track your data in the most efficient and cost-effective way. The types of metrics we currently support are:

  • Counters track a value that can only be incremented.
  • Distributions track a list of values over time in on which you can perform aggregations like max, min, avg.
  • Gauges track a value that can go up and down.
  • Sets track a set of values on which you can perform aggregations such as count_unique.

For more information on metrics in Sentry, see our docs.

§Usage

To collect a metric, use the Metric struct to capture all relevant properties of your metric. Then, use send to send the metric to Sentry:

use std::time::Duration;
use sentry::metrics::Metric;

Metric::count("requests")
    .with_tag("method", "GET")
    .send();

Metric::timing("request.duration", Duration::from_millis(17))
    .with_tag("status_code", "200")
    // unit is added automatically by timing
    .send();

Metric::set("site.visitors", "user1")
    .with_unit("user")
    .send();

§Usage with Cadence

[cadence] is a popular Statsd client for Rust and can be used to send metrics to Sentry. To use Sentry directly with cadence, see the sentry-cadence documentation.

Structs§

Enums§

Type Aliases§