Struct vector_lib::event::metric::Metric
pub struct Metric { /* private fields */ }
Expand description
A metric.
Implementations§
§impl Metric
impl Metric
pub fn new<T>(name: T, kind: MetricKind, value: MetricValue) -> Metric
pub fn new<T>(name: T, kind: MetricKind, value: MetricValue) -> Metric
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
pub fn new_with_metadata<T>( name: T, kind: MetricKind, value: MetricValue, metadata: EventMetadata, ) -> Metric
Creates a new Metric
with the given name
, kind
, value
, and metadata
.
pub fn with_name(self, name: impl Into<String>) -> Metric
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
pub fn with_namespace<T>(self, namespace: Option<T>) -> Metric
Consumes this metric, returning it with an updated series based on the given namespace
.
pub fn with_timestamp(self, timestamp: Option<DateTime<Utc>>) -> Metric
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
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
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
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
.
Consumes this metric, returning it with an updated series based on the given tags
.
pub fn with_value(self, value: MetricValue) -> Metric
pub fn with_value(self, value: MetricValue) -> Metric
Consumes this metric, returning it with an updated value.
pub 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.
pub fn data(&self) -> &MetricData
pub fn data(&self) -> &MetricData
Gets a reference to the data of this metric.
pub 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.
pub fn metadata(&self) -> &EventMetadata
pub fn metadata(&self) -> &EventMetadata
Gets a reference to the metadata of this metric.
pub 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.
pub 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.
pub fn namespace(&self) -> Option<&str>
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>
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.
pub 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.
pub fn interval_ms(&self) -> Option<NonZero<u32>>
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
pub fn value(&self) -> &MetricValue
Gets a reference to the value of this metric.
pub 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.
pub fn kind(&self) -> MetricKind
pub fn kind(&self) -> MetricKind
Gets the kind of this metric.
pub fn time(&self) -> MetricTime
pub fn time(&self) -> MetricTime
Gets the time information of this metric.
pub fn into_parts(self) -> (MetricSeries, MetricData, EventMetadata)
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
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
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
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>
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.
pub 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
pub 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
pub 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>, )
pub fn zero(&mut self)
pub fn zero(&mut self)
Zeroes out the data in this metric.
pub 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.
pub 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
.
pub 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§
§impl AsRef<MetricData> for Metric
impl AsRef<MetricData> for Metric
§fn as_ref(&self) -> &MetricData
fn as_ref(&self) -> &MetricData
§impl AsRef<MetricValue> for Metric
impl AsRef<MetricValue> for Metric
§fn as_ref(&self) -> &MetricValue
fn as_ref(&self) -> &MetricValue
§impl ByteSizeOf for Metric
impl ByteSizeOf for Metric
§impl Configurable for Metric
impl Configurable for Metric
§fn referenceable_name() -> Option<&'static str>
fn referenceable_name() -> Option<&'static str>
§fn generate_schema(
schema_gen: &RefCell<SchemaGenerator>,
) -> Result<SchemaObject, GenerateError>
fn generate_schema( schema_gen: &RefCell<SchemaGenerator>, ) -> Result<SchemaObject, GenerateError>
§fn is_optional() -> boolwhere
Self: Sized,
fn is_optional() -> boolwhere
Self: Sized,
§fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>where
Self: Sized,
fn validate_metadata(_metadata: &Metadata) -> Result<(), GenerateError>where
Self: Sized,
§fn as_configurable_ref() -> ConfigurableRefwhere
Self: Sized + 'static,
fn as_configurable_ref() -> ConfigurableRefwhere
Self: Sized + 'static,
§impl<'de> Deserialize<'de> for Metric
impl<'de> Deserialize<'de> for Metric
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metric, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metric, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Display for Metric
impl Display for Metric
§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
§impl EstimatedJsonEncodedSizeOf for Metric
impl EstimatedJsonEncodedSizeOf for Metric
fn estimated_json_encoded_size_of(&self) -> JsonSize
§impl EventContainer for Metric
impl EventContainer for Metric
§fn into_events(self) -> <Metric as EventContainer>::IntoIter
fn into_events(self) -> <Metric as EventContainer>::IntoIter
Event
.§impl Finalizable for Metric
impl Finalizable for Metric
§fn take_finalizers(&mut self) -> EventFinalizers
fn take_finalizers(&mut self) -> EventFinalizers
§impl<'a> From<&'a mut Metric> for EventMutRef<'a>
impl<'a> From<&'a mut Metric> for EventMutRef<'a>
§fn from(metric: &'a mut Metric) -> EventMutRef<'a>
fn from(metric: &'a mut Metric) -> EventMutRef<'a>
§impl From<Metric> for EventArray
impl From<Metric> for EventArray
§fn from(metric: Metric) -> EventArray
fn from(metric: Metric) -> EventArray
§impl From<Metric> for WithMetadata<Metric>
impl From<Metric> for WithMetadata<Metric>
§fn from(metric: Metric) -> WithMetadata<Metric>
fn from(metric: Metric) -> WithMetadata<Metric>
§impl GetEventCountTags for Metric
impl GetEventCountTags for Metric
§impl Serialize for Metric
impl Serialize for Metric
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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