Struct opentelemetry::sdk::metrics::Instrument
source · pub struct Instrument {
pub name: Cow<'static, str>,
pub description: Cow<'static, str>,
pub kind: Option<InstrumentKind>,
pub unit: Unit,
pub scope: InstrumentationLibrary,
}
Available on crate feature
metrics
only.Expand description
Describes properties an instrument is created with, also used for filtering in Views.
Example
Instruments can be used as criteria for 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 instrument.
description: Cow<'static, str>
describes the purpose of the instrument.
kind: Option<InstrumentKind>
The functional group of the instrument.
unit: Unit
Unit is the unit of measurement recorded by the instrument.
scope: InstrumentationLibrary
The instrumentation that created the instrument.
Implementations§
source§impl Instrument
impl Instrument
sourcepub fn new() -> Instrument
pub fn new() -> Instrument
Create a new instrument with default values
sourcepub fn description(
self,
description: impl Into<Cow<'static, str>>
) -> Instrument
pub fn description( self, description: impl Into<Cow<'static, str>> ) -> Instrument
Set the instrument description.
sourcepub fn unit(self, unit: Unit) -> Instrument
pub fn unit(self, unit: Unit) -> Instrument
Set the instrument unit.
sourcepub fn scope(self, scope: InstrumentationLibrary) -> Instrument
pub fn scope(self, scope: InstrumentationLibrary) -> Instrument
Set the instrument scope.
Trait Implementations§
source§impl Clone for Instrument
impl Clone for Instrument
source§fn clone(&self) -> Instrument
fn clone(&self) -> Instrument
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Instrument
impl Debug for Instrument
source§impl Default for Instrument
impl Default for Instrument
source§fn default() -> Instrument
fn default() -> Instrument
Returns the “default value” for a type. Read more
source§impl PartialEq<Instrument> for Instrument
impl PartialEq<Instrument> for Instrument
source§fn eq(&self, other: &Instrument) -> bool
fn eq(&self, other: &Instrument) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for Instrument
Auto Trait Implementations§
impl RefUnwindSafe for Instrument
impl Send for Instrument
impl Sync for Instrument
impl Unpin for Instrument
impl UnwindSafe for Instrument
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more