Struct vector_core::event::metric::Metric
source · pub struct Metric { /* private fields */ }
Expand description
A metric.
Implementations§
source§impl Metric
impl Metric
sourcepub fn new<T: Into<String>>(
name: T,
kind: MetricKind,
value: MetricValue,
) -> Self
pub fn new<T: Into<String>>( name: T, kind: MetricKind, value: MetricValue, ) -> Self
Creates a new Metric
with the given name
, kind
, and value
.
sourcepub fn new_with_metadata<T: Into<String>>(
name: T,
kind: MetricKind,
value: MetricValue,
metadata: EventMetadata,
) -> Self
pub fn new_with_metadata<T: Into<String>>( name: T, kind: MetricKind, value: MetricValue, metadata: EventMetadata, ) -> Self
Creates a new Metric
with the given name
, kind
, value
, and metadata
.
sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Consumes this metric, returning it with an updated series based on the given name
.
sourcepub fn with_namespace<T: Into<String>>(self, namespace: Option<T>) -> Self
pub fn with_namespace<T: Into<String>>(self, namespace: Option<T>) -> Self
Consumes this metric, returning it with an updated series based on the given namespace
.
sourcepub fn with_timestamp(self, timestamp: Option<DateTime<Utc>>) -> Self
pub fn with_timestamp(self, timestamp: Option<DateTime<Utc>>) -> Self
Consumes this metric, returning it with an updated timestamp.
sourcepub fn with_interval_ms(self, interval_ms: Option<NonZeroU32>) -> Self
pub fn with_interval_ms(self, interval_ms: Option<NonZeroU32>) -> Self
Consumes this metric, returning it with an updated interval.
pub fn add_finalizer(&mut self, finalizer: EventFinalizer)
sourcepub fn with_batch_notifier(self, batch: &BatchNotifier) -> Self
pub fn with_batch_notifier(self, batch: &BatchNotifier) -> Self
Consumes this metric, returning it with an updated set of event finalizers attached to batch
.
sourcepub fn with_batch_notifier_option(self, batch: &Option<BatchNotifier>) -> Self
pub fn with_batch_notifier_option(self, batch: &Option<BatchNotifier>) -> Self
Consumes this metric, returning it with an optionally updated set of event finalizers attached to batch
.
Consumes this metric, returning it with an updated series based on the given tags
.
sourcepub fn with_value(self, value: MetricValue) -> Self
pub fn with_value(self, value: MetricValue) -> Self
Consumes this metric, returning it with an updated value.
sourcepub fn series(&self) -> &MetricSeries
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.
sourcepub fn data(&self) -> &MetricData
pub fn data(&self) -> &MetricData
Gets a reference to the data of this metric.
sourcepub fn data_mut(&mut self) -> &mut MetricData
pub fn data_mut(&mut self) -> &mut MetricData
Gets a mutable reference to the data of this metric.
sourcepub fn metadata(&self) -> &EventMetadata
pub fn metadata(&self) -> &EventMetadata
Gets a reference to the metadata of this metric.
sourcepub fn metadata_mut(&mut self) -> &mut EventMetadata
pub fn metadata_mut(&mut self) -> &mut EventMetadata
Gets a mutable reference to the metadata of this metric.
sourcepub fn name(&self) -> &str
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.
sourcepub fn namespace(&self) -> Option<&str>
pub fn namespace(&self) -> Option<&str>
Gets a reference to the namespace of this metric, if it exists.
sourcepub fn take_namespace(&mut self) -> Option<String>
pub fn take_namespace(&mut self) -> Option<String>
Takes the namespace out of this metric, if it exists, leaving it empty.
Gets a reference to the tags of this metric, if they exist.
Gets a mutable reference to the tags of this metric, if they exist.
sourcepub fn timestamp(&self) -> Option<DateTime<Utc>>
pub fn timestamp(&self) -> Option<DateTime<Utc>>
Gets a reference to the timestamp of this metric, if it exists.
sourcepub fn interval_ms(&self) -> Option<NonZeroU32>
pub fn interval_ms(&self) -> Option<NonZeroU32>
Gets a reference to the interval (in milliseconds) covered by this metric, if it exists.
sourcepub fn value(&self) -> &MetricValue
pub fn value(&self) -> &MetricValue
Gets a reference to the value of this metric.
sourcepub fn value_mut(&mut self) -> &mut MetricValue
pub fn value_mut(&mut self) -> &mut MetricValue
Gets a mutable reference to the value of this metric.
sourcepub fn kind(&self) -> MetricKind
pub fn kind(&self) -> MetricKind
Gets the kind of this metric.
sourcepub fn time(&self) -> MetricTime
pub fn time(&self) -> MetricTime
Gets the time information of this metric.
sourcepub fn into_parts(self) -> (MetricSeries, MetricData, EventMetadata)
pub fn into_parts(self) -> (MetricSeries, MetricData, EventMetadata)
Decomposes a Metric
into its individual parts.
sourcepub fn from_parts(
series: MetricSeries,
data: MetricData,
metadata: EventMetadata,
) -> Self
pub fn from_parts( series: MetricSeries, data: MetricData, metadata: EventMetadata, ) -> Self
Creates a Metric
directly from the raw components of another metric.
sourcepub fn into_absolute(self) -> Self
pub fn into_absolute(self) -> Self
Consumes this metric, returning it as an absolute metric.
If the metric was already absolute, nothing is changed.
sourcepub fn into_incremental(self) -> Self
pub fn into_incremental(self) -> Self
Consumes this metric, returning it as an incremental metric.
If the metric was already incremental, nothing is changed.
sourcepub fn remove_tag(&mut self, key: &str) -> Option<String>
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.
Removes all the tags.
sourcepub fn tag_matches(&self, name: &str, value: &str) -> bool
pub fn tag_matches(&self, name: &str, value: &str) -> bool
Returns true
if name
tag is present, and matches the provided value
sourcepub fn tag_value(&self, name: &str) -> Option<String>
pub fn tag_value(&self, name: &str) -> Option<String>
Returns the string value of a tag, if it exists
sourcepub fn replace_tag(&mut self, name: String, value: String) -> Option<String>
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>, )
sourcepub fn add(&mut self, other: impl AsRef<MetricData>) -> bool
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.
sourcepub fn update(&mut self, other: impl AsRef<MetricData>) -> bool
pub fn update(&mut self, other: impl AsRef<MetricData>) -> bool
Updates this metric by adding the data from other
.
sourcepub fn subtract(&mut self, other: impl AsRef<MetricData>) -> bool
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.
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§
source§impl AsRef<MetricData> for Metric
impl AsRef<MetricData> for Metric
source§fn as_ref(&self) -> &MetricData
fn as_ref(&self) -> &MetricData
source§impl AsRef<MetricValue> for Metric
impl AsRef<MetricValue> for Metric
source§fn as_ref(&self) -> &MetricValue
fn as_ref(&self) -> &MetricValue
source§impl ByteSizeOf for Metric
impl ByteSizeOf for Metric
source§impl Configurable for Metric
impl Configurable for Metric
source§fn referenceable_name() -> Option<&'static str>
fn referenceable_name() -> Option<&'static str>
source§fn generate_schema(
schema_gen: &RefCell<SchemaGenerator>,
) -> Result<SchemaObject, GenerateError>
fn generate_schema( schema_gen: &RefCell<SchemaGenerator>, ) -> Result<SchemaObject, GenerateError>
source§fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>where
Self: Sized,
fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>where
Self: Sized,
source§fn as_configurable_ref() -> ConfigurableRefwhere
Self: Sized + 'static,
fn as_configurable_ref() -> ConfigurableRefwhere
Self: Sized + 'static,
source§impl<'de> Deserialize<'de> for Metric
impl<'de> Deserialize<'de> for Metric
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for Metric
impl Display for Metric
source§fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>
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
source§impl EstimatedJsonEncodedSizeOf for Metric
impl EstimatedJsonEncodedSizeOf for Metric
fn estimated_json_encoded_size_of(&self) -> JsonSize
source§impl EventContainer for Metric
impl EventContainer for Metric
source§fn into_events(self) -> Self::IntoIter
fn into_events(self) -> Self::IntoIter
Event
.source§impl EventDataEq for Metric
impl EventDataEq for Metric
fn event_data_eq(&self, other: &Self) -> bool
source§impl Finalizable for Metric
impl Finalizable for Metric
source§fn take_finalizers(&mut self) -> EventFinalizers
fn take_finalizers(&mut self) -> EventFinalizers
source§impl<'a> From<&'a mut Metric> for EventMutRef<'a>
impl<'a> From<&'a mut Metric> for EventMutRef<'a>
source§impl From<Metric> for EventArray
impl From<Metric> for EventArray
source§impl GetEventCountTags for Metric
impl GetEventCountTags for Metric
source§impl PartialEq for Metric
impl PartialEq for Metric
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§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> FromLuaMulti for Twhere
T: FromLua,
impl<T> FromLuaMulti for Twhere
T: FromLua,
§fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
impl<Source, Target> OctetsInto<Target> for Sourcewhere
Target: OctetsFrom<Source>,
type Error = <Target as OctetsFrom<Source>>::Error
§fn try_octets_into(
self,
) -> Result<Target, <Source as OctetsInto<Target>>::Error>
fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>
§fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
fn octets_into(self) -> Targetwhere
Self::Error: Into<Infallible>,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
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,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more