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

source

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.

source

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.

source

pub fn with_tags<T, K, V>(self, tags: T) -> Self
where T: IntoIterator<Item = (K, V)>, K: Into<MetricStr>, V: Into<MetricStr>,

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.

source

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.

source

pub fn finish(self) -> Metric

Builds the metric.

source

pub fn send(self)

Sends the metric to the current client.

This is a shorthand for .finish().send(). If there is no client on the current Hub, the metric is dropped.

Trait Implementations§

source§

impl Debug for MetricBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V