Struct sentry_core::metrics::MetricBuilder
source · pub struct MetricBuilder { /* private fields */ }
Expand description
A builder for metrics.
Use one of the Metric
constructors to create a new builder. See the struct-level docs for
examples of how to build metrics.
Implementations§
source§impl MetricBuilder
impl MetricBuilder
sourcepub fn with_unit(self, unit: impl Into<MetricUnit>) -> Self
pub fn with_unit(self, unit: impl Into<MetricUnit>) -> Self
Sets the unit for the metric.
The unit augments the metric value by giving it a magnitude and semantics. Some units have
special support when rendering metrics or their values in Sentry, such as for timings. See
MetricUnit
for more information on the supported units. The unit can be set to
MetricUnit::None
to indicate that the metric has no unit, or to MetricUnit::Custom
to indicate a user-defined unit.
By default, the unit is set to MetricUnit::None
.
sourcepub fn with_tag(
self,
name: impl Into<MetricStr>,
value: impl Into<MetricStr>,
) -> Self
pub fn with_tag( self, name: impl Into<MetricStr>, value: impl Into<MetricStr>, ) -> Self
Adds a tag to the metric.
Tags allow you to add dimensions to metrics. They are key-value pairs that can be filtered or grouped by in Sentry.
When sent to Sentry via MetricBuilder::send
or when added to a
Client
, the client may add default tags to the metrics, such as the
release
or the environment
from the Scope.
Adds multiple tags to the metric.
Tags allow you to add dimensions to metrics. They are key-value pairs that can be filtered or grouped by in Sentry.
When sent to Sentry via MetricBuilder::send
or when added to a
Client
, the client may add default tags to the metrics, such as the
release
or the environment
from the Scope.
sourcepub fn with_time(self, time: SystemTime) -> Self
pub fn with_time(self, time: SystemTime) -> Self
Sets the timestamp for the metric.
By default, the timestamp is set to the current time when the metric is built or sent.