Struct opentelemetry_sdk::metrics::Stream

source ·
#[non_exhaustive]
pub struct Stream { pub name: Cow<'static, str>, pub description: Cow<'static, str>, pub unit: Cow<'static, str>, pub aggregation: Option<Aggregation>, pub allowed_attribute_keys: Option<Arc<HashSet<Key>>>, }
Expand description

Describes the stream of data an instrument produces.

§Example

Streams can be used as masks in views.

use opentelemetry_sdk::metrics::{new_view, Aggregation, Instrument, Stream};

let criteria = Instrument::new().name("counter_*");
let mask = Stream::new().aggregation(Aggregation::Sum);

let view = new_view(criteria, mask);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: Cow<'static, str>

The human-readable identifier of the stream.

§description: Cow<'static, str>

Describes the purpose of the data.

§unit: Cow<'static, str>

the unit of measurement recorded.

§aggregation: Option<Aggregation>

Aggregation the stream uses for an instrument.

§allowed_attribute_keys: Option<Arc<HashSet<Key>>>

An allow-list of attribute keys that will be preserved for the stream.

Any attribute recorded for the stream with a key not in this set will be dropped. If the set is empty, all attributes will be dropped, if None all attributes will be kept.

Implementations§

source§

impl Stream

source

pub fn new() -> Self

Create a new stream with empty values.

source

pub fn name(self, name: impl Into<Cow<'static, str>>) -> Self

Set the stream name.

source

pub fn description(self, description: impl Into<Cow<'static, str>>) -> Self

Set the stream description.

source

pub fn unit(self, unit: impl Into<Cow<'static, str>>) -> Self

Set the stream unit.

source

pub fn aggregation(self, aggregation: Aggregation) -> Self

Set the stream aggregation.

source

pub fn allowed_attribute_keys( self, attribute_keys: impl IntoIterator<Item = Key>, ) -> Self

Set the stream allowed attribute keys.

Any attribute recorded for the stream with a key not in this set will be dropped. If this set is empty all attributes will be dropped.

Trait Implementations§

source§

impl Debug for Stream

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Stream

source§

fn default() -> Stream

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Stream

§

impl RefUnwindSafe for Stream

§

impl Send for Stream

§

impl Sync for Stream

§

impl Unpin for Stream

§

impl UnwindSafe for Stream

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> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more