Struct vector_lib::event::metric::Metric

pub struct Metric { /* private fields */ }
Expand description

A metric.

Implementations§

§

impl Metric

pub fn new<T>(name: T, kind: MetricKind, value: MetricValue) -> Metric
where T: Into<String>,

Creates a new Metric with the given name, kind, and value.

pub fn new_with_metadata<T>( name: T, kind: MetricKind, value: MetricValue, metadata: EventMetadata, ) -> Metric
where T: Into<String>,

Creates a new Metric with the given name, kind, value, and metadata.

pub fn with_name(self, name: impl Into<String>) -> Metric

Consumes this metric, returning it with an updated series based on the given name.

pub fn with_namespace<T>(self, namespace: Option<T>) -> Metric
where T: Into<String>,

Consumes this metric, returning it with an updated series based on the given namespace.

pub fn with_timestamp(self, timestamp: Option<DateTime<Utc>>) -> Metric

Consumes this metric, returning it with an updated timestamp.

pub fn with_interval_ms(self, interval_ms: Option<NonZero<u32>>) -> Metric

Consumes this metric, returning it with an updated interval.

pub fn add_finalizer(&mut self, finalizer: EventFinalizer)

pub fn with_batch_notifier(self, batch: &BatchNotifier) -> Metric

Consumes this metric, returning it with an updated set of event finalizers attached to batch.

pub fn with_batch_notifier_option(self, batch: &Option<BatchNotifier>) -> Metric

Consumes this metric, returning it with an optionally updated set of event finalizers attached to batch.

pub fn with_tags(self, tags: Option<MetricTags>) -> Metric

Consumes this metric, returning it with an updated series based on the given tags.

pub fn with_value(self, value: MetricValue) -> Metric

Consumes this metric, returning it with an updated value.

pub fn series(&self) -> &MetricSeries

Gets a reference to the series of this metric.

The “series” is the name of the metric itself, including any tags. In other words, it is the unique identifier for a metric, although metrics of different values (counter vs gauge) may be able to co-exist in outside metrics implementations with identical series.

pub fn data(&self) -> &MetricData

Gets a reference to the data of this metric.

pub fn data_mut(&mut self) -> &mut MetricData

Gets a mutable reference to the data of this metric.

pub fn metadata(&self) -> &EventMetadata

Gets a reference to the metadata of this metric.

pub fn metadata_mut(&mut self) -> &mut EventMetadata

Gets a mutable reference to the metadata of this metric.

pub fn name(&self) -> &str

Gets a reference to the name of this metric.

The name of the metric does not include the namespace or tags.

pub fn namespace(&self) -> Option<&str>

Gets a reference to the namespace of this metric, if it exists.

pub fn take_namespace(&mut self) -> Option<String>

Takes the namespace out of this metric, if it exists, leaving it empty.

pub fn tags(&self) -> Option<&MetricTags>

Gets a reference to the tags of this metric, if they exist.

pub fn tags_mut(&mut self) -> Option<&mut MetricTags>

Gets a mutable reference to the tags of this metric, if they exist.

pub fn timestamp(&self) -> Option<DateTime<Utc>>

Gets a reference to the timestamp of this metric, if it exists.

pub fn interval_ms(&self) -> Option<NonZero<u32>>

Gets a reference to the interval (in milliseconds) covered by this metric, if it exists.

pub fn value(&self) -> &MetricValue

Gets a reference to the value of this metric.

pub fn value_mut(&mut self) -> &mut MetricValue

Gets a mutable reference to the value of this metric.

pub fn kind(&self) -> MetricKind

Gets the kind of this metric.

pub fn time(&self) -> MetricTime

Gets the time information of this metric.

pub fn into_parts(self) -> (MetricSeries, MetricData, EventMetadata)

Decomposes a Metric into its individual parts.

pub fn from_parts( series: MetricSeries, data: MetricData, metadata: EventMetadata, ) -> Metric

Creates a Metric directly from the raw components of another metric.

pub fn into_absolute(self) -> Metric

Consumes this metric, returning it as an absolute metric.

If the metric was already absolute, nothing is changed.

pub fn into_incremental(self) -> Metric

Consumes this metric, returning it as an incremental metric.

If the metric was already incremental, nothing is changed.

pub fn remove_tag(&mut self, key: &str) -> Option<String>

Removes a tag from this metric, returning the value of the tag if the tag was previously in the metric.

pub fn remove_tags(&mut self)

Removes all the tags.

pub fn tag_matches(&self, name: &str, value: &str) -> bool

Returns true if name tag is present, and matches the provided value

pub fn tag_value(&self, name: &str) -> Option<String>

Returns the string value of a tag, if it exists

pub fn replace_tag(&mut self, name: String, value: String) -> Option<String>

Inserts a tag into this metric.

If the metric did not have this tag, None will be returned. Otherwise, Some(String) will be returned, containing the previous value of the tag.

Note: This will create the tags map if it is not present.

pub fn set_multi_value_tag( &mut self, name: String, values: impl IntoIterator<Item = TagValue>, )

pub fn zero(&mut self)

Zeroes out the data in this metric.

pub fn add(&mut self, other: impl AsRef<MetricData>) -> bool

Adds the data from the other metric to this one.

The other metric must be incremental and contain the same value type as this one.

pub fn update(&mut self, other: impl AsRef<MetricData>) -> bool

Updates this metric by adding the data from other.

pub fn subtract(&mut self, other: impl AsRef<MetricData>) -> bool

Subtracts the data from the other metric from this one.

The other metric must contain the same value type as this one.

pub fn reduce_tags_to_single(&mut self)

Reduces all the tag values to their single value, discarding any for which that value would be null. If the result is empty, the tag set is dropped.

Trait Implementations§

§

impl AsRef<MetricData> for Metric

§

fn as_ref(&self) -> &MetricData

Converts this type into a shared reference of the (usually inferred) input type.
§

impl AsRef<MetricValue> for Metric

§

fn as_ref(&self) -> &MetricValue

Converts this type into a shared reference of the (usually inferred) input type.
§

impl ByteSizeOf for Metric

§

fn allocated_bytes(&self) -> usize

Returns the allocated bytes of this type Read more
§

fn size_of(&self) -> usize

Returns the in-memory size of this type Read more
§

impl Clone for Metric

§

fn clone(&self) -> Metric

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Configurable for Metric

§

fn referenceable_name() -> Option<&'static str>

Gets the referenceable name of this value, if any. Read more
§

fn metadata() -> Metadata

Gets the metadata for this value.
§

fn generate_schema( schema_gen: &RefCell<SchemaGenerator>, ) -> Result<SchemaObject, GenerateError>

Generates the schema for this value. Read more
§

fn is_optional() -> bool
where Self: Sized,

Whether or not this value is optional. Read more
§

fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>
where Self: Sized,

Validates the given metadata against this type. Read more
§

fn as_configurable_ref() -> ConfigurableRef
where Self: Sized + 'static,

Create a new configurable reference table.
§

impl Debug for Metric

§

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

Formats the value using the given formatter. Read more
§

impl<'de> Deserialize<'de> for Metric

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Metric, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl Display for Metric

§

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

Display a metric using something like Prometheus’ text format:

TIMESTAMP NAMESPACE_NAME{TAGS} KIND DATA

TIMESTAMP is in ISO 8601 format with UTC time zone.

KIND is either = for absolute metrics, or + for incremental metrics.

DATA is dependent on the type of metric, and is a simplified representation of the data contents. In particular, distributions, histograms, and summaries are represented as a list of X@Y words, where X is the rate, count, or quantile, and Y is the value or bucket.

example:

2020-08-12T20:23:37.248661343Z vector_received_bytes_total{component_kind="sink",component_type="blackhole"} = 6391
§

impl EstimatedJsonEncodedSizeOf for Metric

§

impl EventContainer for Metric

§

type IntoIter = Once<Event>

The type of Iterator used to turn this container into events.
§

fn len(&self) -> usize

The number of events in this container.
§

fn is_empty(&self) -> bool

Is this container empty?
§

fn into_events(self) -> <Metric as EventContainer>::IntoIter

Turn this container into an iterator over Event.
§

impl EventDataEq for Metric

§

fn event_data_eq(&self, other: &Metric) -> bool

§

impl Finalizable for Metric

§

fn take_finalizers(&mut self) -> EventFinalizers

Consumes the finalizers of this object. Read more
§

impl<'a> From<&'a Metric> for EventRef<'a>

§

fn from(metric: &'a Metric) -> EventRef<'a>

Converts to this type from the input type.
§

impl<'a> From<&'a mut Metric> for EventMutRef<'a>

§

fn from(metric: &'a mut Metric) -> EventMutRef<'a>

Converts to this type from the input type.
§

impl From<Metric> for Event

§

fn from(metric: Metric) -> Event

Converts to this type from the input type.
§

impl From<Metric> for EventArray

§

fn from(metric: Metric) -> EventArray

Converts to this type from the input type.
§

impl From<Metric> for Metric

§

fn from(metric: Metric) -> Metric

Converts to this type from the input type.
§

impl From<Metric> for Metric

§

fn from(metric: Metric) -> Metric

Converts to this type from the input type.
§

impl From<Metric> for WithMetadata<Metric>

§

fn from(metric: Metric) -> WithMetadata<Metric>

Converts to this type from the input type.
§

impl FromLua for Metric

§

fn from_lua(value: Value, _: &Lua) -> Result<Metric, Error>

Performs the conversion.
§

impl GetEventCountTags for Metric

§

impl PartialEq for Metric

§

fn eq(&self, other: &Metric) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Serialize for Metric

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl ToValue for Metric

§

fn to_value(&self) -> Value

Convert this value into a serde_json::Value. Must not fail.
§

impl StructuralPartialEq for Metric

Auto Trait Implementations§

§

impl Freeze for Metric

§

impl !RefUnwindSafe for Metric

§

impl Send for Metric

§

impl Sync for Metric

§

impl Unpin for Metric

§

impl !UnwindSafe for Metric

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromLuaMulti for T
where T: FromLua,

§

fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>

Performs the conversion. Read more
§

fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>

§

unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>

§

unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

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

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

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

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

§

type Error = <Target as OctetsFrom<Source>>::Error

§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>

Change the foreground color to black
§

fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>

Change the background color to black
§

fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>

Change the foreground color to red
§

fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>

Change the background color to red
§

fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>

Change the foreground color to green
§

fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>

Change the background color to green
§

fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>

Change the background color to yellow
§

fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>

Change the foreground color to blue
§

fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>

Change the background color to blue
§

fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to magenta
§

fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>

Change the foreground color to purple
§

fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>

Change the background color to purple
§

fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>

Change the background color to cyan
§

fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>

Change the foreground color to white
§

fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>

Change the background color to white
§

fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>

Change the background color to the terminal default
§

fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>

Change the background color to bright red
§

fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>

Change the background color to bright white
§

fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>

Make the text bold
§

fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>

Make the text dim
§

fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>

Make the text italicized
§

fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>

Make the text italicized
Make the text blink
Make the text blink (but fast!)
§

fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>

Swap the foreground and background colors
§

fn hidden<'a>(&'a self) -> HiddenDisplay<'a, Self>

Hide the text
§

fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T