Module sentry_core::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§
- A metric value that contains a numeric value and metadata to be sent to Sentry.
- A builder for metrics.
- Error emitted from
Metric::parse_statsd
for invalid metric strings. - An error parsing a
MetricUnit
or one of its variants.
Enums§
- Time duration units used in
MetricUnit::Duration
. - Units of fraction used in
MetricUnit::Fraction
. - Size of information derived from bytes, used in
MetricUnit::Information
. - The unit of measurement of a metric value.
- The value of a
Metric
, indicating its type.
Type Aliases§
- Type used for
MetricValue::Counter
. - Type used for
MetricValue::Distribution
. - Type used for
MetricValue::Gauge
. - Type alias for strings used in
Metric
for names and tags. - Type used for
MetricValue::Set
.