From 807876c61bd14fcecf727d2e4214fc967f51147d Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 17:18:00 -0400 Subject: [PATCH 01/17] Add MetricName into vector-common --- Cargo.lock | 1 + clippy.toml | 6 ++ lib/vector-common/Cargo.toml | 1 + .../src/internal_event/bytes_received.rs | 8 ++- .../src/internal_event/bytes_sent.rs | 8 ++- .../component_events_dropped.rs | 8 ++- .../component_events_timed_out.rs | 10 +-- .../src/internal_event/events_received.rs | 12 ++-- .../src/internal_event/events_sent.rs | 18 +++--- .../src/internal_event/metric_name.rs | 37 +++++++++++ lib/vector-common/src/internal_event/mod.rs | 2 + .../src/internal_event/service.rs | 8 ++- lib/vector-common/src/lib.rs | 61 +++++++++++++++++++ 13 files changed, 151 insertions(+), 29 deletions(-) create mode 100644 lib/vector-common/src/internal_event/metric_name.rs diff --git a/Cargo.lock b/Cargo.lock index 9bab182e05373..14687b0db7d70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13064,6 +13064,7 @@ dependencies = [ "serde_json", "smallvec", "stream-cancel", + "strum 0.28.0", "tokio", "tracing 0.1.44", "vector-common-macros", diff --git a/clippy.toml b/clippy.toml index cbd8c640fdb71..53065808f4629 100644 --- a/clippy.toml +++ b/clippy.toml @@ -8,6 +8,12 @@ disallowed-methods = [ { path = "vrl::stdlib::all", reason = "Use `vector_vrl_functions::all()` instead for consistency across all Vector VRL functions." }, ] +disallowed-macros = [ + { path = "metrics::counter", reason = "Use the `counter!` macro from `vector_common` with a `MetricName` variant instead of a raw string." }, + { path = "metrics::histogram", reason = "Use the `histogram!` macro from `vector_common` with a `MetricName` variant instead of a raw string." }, + { path = "metrics::gauge", reason = "Use the `gauge!` macro from `vector_common` with a `MetricName` variant instead of a raw string." }, +] + disallowed-types = [ { path = "once_cell::sync::OnceCell", reason = "Use `std::sync::OnceLock` instead." }, { path = "once_cell::unsync::OnceCell", reason = "Use `std::cell::OnceCell` instead." }, diff --git a/lib/vector-common/Cargo.toml b/lib/vector-common/Cargo.toml index 95098f19b1bd3..a583641c68cec 100644 --- a/lib/vector-common/Cargo.toml +++ b/lib/vector-common/Cargo.toml @@ -48,6 +48,7 @@ pin-project.workspace = true serde.workspace = true serde_json.workspace = true smallvec = { version = "1", default-features = false } +strum.workspace = true stream-cancel = { version = "0.8.2", default-features = false } tokio = { workspace = true, features = ["macros", "time"] } tracing.workspace = true diff --git a/lib/vector-common/src/internal_event/bytes_received.rs b/lib/vector-common/src/internal_event/bytes_received.rs index 98044ecb84570..47b016ed390bc 100644 --- a/lib/vector-common/src/internal_event/bytes_received.rs +++ b/lib/vector-common/src/internal_event/bytes_received.rs @@ -1,12 +1,14 @@ -use metrics::{Counter, counter}; +use metrics::Counter; -use super::{ByteSize, Protocol, SharedString}; +use crate::counter; + +use super::{ByteSize, MetricName, Protocol, SharedString}; crate::registered_event!( BytesReceived { protocol: SharedString, } => { - received_bytes: Counter = counter!("component_received_bytes_total", "protocol" => self.protocol.clone()), + received_bytes: Counter = counter!(MetricName::ComponentReceivedBytesTotal, "protocol" => self.protocol.clone()), protocol: SharedString = self.protocol, } diff --git a/lib/vector-common/src/internal_event/bytes_sent.rs b/lib/vector-common/src/internal_event/bytes_sent.rs index 0b2a88247f96c..b9a3f95dbcc06 100644 --- a/lib/vector-common/src/internal_event/bytes_sent.rs +++ b/lib/vector-common/src/internal_event/bytes_sent.rs @@ -1,13 +1,15 @@ -use metrics::{Counter, counter}; +use metrics::Counter; + +use crate::counter; use tracing::trace; -use super::{ByteSize, Protocol, SharedString}; +use super::{ByteSize, MetricName, Protocol, SharedString}; crate::registered_event!( BytesSent { protocol: SharedString, } => { - bytes_sent: Counter = counter!("component_sent_bytes_total", "protocol" => self.protocol.clone()), + bytes_sent: Counter = counter!(MetricName::ComponentSentBytesTotal, "protocol" => self.protocol.clone()), protocol: SharedString = self.protocol, } diff --git a/lib/vector-common/src/internal_event/component_events_dropped.rs b/lib/vector-common/src/internal_event/component_events_dropped.rs index bf45c054e45e1..258a9426deb0d 100644 --- a/lib/vector-common/src/internal_event/component_events_dropped.rs +++ b/lib/vector-common/src/internal_event/component_events_dropped.rs @@ -1,6 +1,8 @@ -use metrics::{Counter, counter}; +use metrics::Counter; -use super::{Count, InternalEvent, InternalEventHandle, RegisterInternalEvent}; +use crate::counter; + +use super::{Count, InternalEvent, InternalEventHandle, MetricName, RegisterInternalEvent}; use crate::NamedInternalEvent; pub const INTENTIONAL: bool = true; @@ -32,7 +34,7 @@ impl<'a, const INTENTIONAL: bool> RegisterInternalEvent fn register(self) -> Self::Handle { Self::Handle { discarded_events: counter!( - "component_discarded_events_total", + MetricName::ComponentDiscardedEventsTotal, "intentional" => if INTENTIONAL { "true" } else { "false" }, ), reason: self.reason, diff --git a/lib/vector-common/src/internal_event/component_events_timed_out.rs b/lib/vector-common/src/internal_event/component_events_timed_out.rs index bf138dd1481c7..9fc0c90a399fd 100644 --- a/lib/vector-common/src/internal_event/component_events_timed_out.rs +++ b/lib/vector-common/src/internal_event/component_events_timed_out.rs @@ -1,13 +1,15 @@ -use metrics::{Counter, counter}; +use metrics::Counter; -use super::Count; +use crate::counter; + +use super::{Count, MetricName}; crate::registered_event! { ComponentEventsTimedOut { reason: &'static str, } => { - timed_out_events: Counter = counter!("component_timed_out_events_total"), - timed_out_requests: Counter = counter!("component_timed_out_requests_total"), + timed_out_events: Counter = counter!(MetricName::ComponentTimedOutEventsTotal), + timed_out_requests: Counter = counter!(MetricName::ComponentTimedOutRequestsTotal), reason: &'static str = self.reason, } diff --git a/lib/vector-common/src/internal_event/events_received.rs b/lib/vector-common/src/internal_event/events_received.rs index 40ba999a8cfca..d5ca521951d3d 100644 --- a/lib/vector-common/src/internal_event/events_received.rs +++ b/lib/vector-common/src/internal_event/events_received.rs @@ -1,13 +1,15 @@ -use metrics::{Counter, Histogram, counter, histogram}; +use metrics::{Counter, Histogram}; + +use crate::{counter, histogram}; use tracing::trace; -use super::CountByteSize; +use super::{CountByteSize, MetricName}; crate::registered_event!( EventsReceived => { - events_count: Histogram = histogram!("component_received_events_count"), - events: Counter = counter!("component_received_events_total"), - event_bytes: Counter = counter!("component_received_event_bytes_total"), + events_count: Histogram = histogram!(MetricName::ComponentReceivedEventsCount), + events: Counter = counter!(MetricName::ComponentReceivedEventsTotal), + event_bytes: Counter = counter!(MetricName::ComponentReceivedEventBytesTotal), } fn emit(&self, data: CountByteSize) { diff --git a/lib/vector-common/src/internal_event/events_sent.rs b/lib/vector-common/src/internal_event/events_sent.rs index 21e11260b2d38..08d1b42d29a36 100644 --- a/lib/vector-common/src/internal_event/events_sent.rs +++ b/lib/vector-common/src/internal_event/events_sent.rs @@ -1,9 +1,11 @@ use std::sync::Arc; -use metrics::{Counter, counter}; +use metrics::Counter; + +use crate::counter; use tracing::trace; -use super::{CountByteSize, OptionalTag, Output, SharedString}; +use super::{CountByteSize, MetricName, OptionalTag, Output, SharedString}; use crate::config::ComponentKey; pub const DEFAULT_OUTPUT: &str = "_default"; @@ -13,14 +15,14 @@ crate::registered_event!( output: Option, } => { events: Counter = if let Some(output) = &self.output { - counter!("component_sent_events_total", "output" => output.clone()) + counter!(MetricName::ComponentSentEventsTotal, "output" => output.clone()) } else { - counter!("component_sent_events_total") + counter!(MetricName::ComponentSentEventsTotal) }, event_bytes: Counter = if let Some(output) = &self.output { - counter!("component_sent_event_bytes_total", "output" => output.clone()) + counter!(MetricName::ComponentSentEventBytesTotal, "output" => output.clone()) } else { - counter!("component_sent_event_bytes_total") + counter!(MetricName::ComponentSentEventBytesTotal) }, output: Option = self.output, } @@ -75,10 +77,10 @@ crate::registered_event!( service: OptionalTag, } => { events: Counter = { - counter!("component_sent_events_total", &make_tags(&self.source, &self.service)) + counter!(MetricName::ComponentSentEventsTotal, &make_tags(&self.source, &self.service)) }, event_bytes: Counter = { - counter!("component_sent_event_bytes_total", &make_tags(&self.source, &self.service)) + counter!(MetricName::ComponentSentEventBytesTotal, &make_tags(&self.source, &self.service)) }, } diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs new file mode 100644 index 0000000000000..a9c7ed0f1de10 --- /dev/null +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -0,0 +1,37 @@ +use strum::{AsRefStr, Display, EnumIter}; + +/// Canonical list of all per-component internal metric names emitted by Vector. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display, AsRefStr, EnumIter)] +#[strum(serialize_all = "snake_case")] +pub enum MetricName { + ComponentReceivedEventsTotal, + ComponentReceivedEventBytesTotal, + ComponentReceivedEventsCount, + ComponentReceivedBytesTotal, + ComponentSentEventsTotal, + ComponentSentEventBytesTotal, + ComponentSentBytesTotal, + ComponentDiscardedEventsTotal, + ComponentErrorsTotal, + ComponentTimedOutEventsTotal, + ComponentTimedOutRequestsTotal, +} + +impl MetricName { + #[must_use] + pub const fn as_str(self) -> &'static str { + match self { + Self::ComponentReceivedEventsTotal => "component_received_events_total", + Self::ComponentReceivedEventBytesTotal => "component_received_event_bytes_total", + Self::ComponentReceivedEventsCount => "component_received_events_count", + Self::ComponentReceivedBytesTotal => "component_received_bytes_total", + Self::ComponentSentEventsTotal => "component_sent_events_total", + Self::ComponentSentEventBytesTotal => "component_sent_event_bytes_total", + Self::ComponentSentBytesTotal => "component_sent_bytes_total", + Self::ComponentDiscardedEventsTotal => "component_discarded_events_total", + Self::ComponentErrorsTotal => "component_errors_total", + Self::ComponentTimedOutEventsTotal => "component_timed_out_events_total", + Self::ComponentTimedOutRequestsTotal => "component_timed_out_requests_total", + } + } +} diff --git a/lib/vector-common/src/internal_event/mod.rs b/lib/vector-common/src/internal_event/mod.rs index 272e2344900e3..7ee08bd541d37 100644 --- a/lib/vector-common/src/internal_event/mod.rs +++ b/lib/vector-common/src/internal_event/mod.rs @@ -5,6 +5,7 @@ pub mod component_events_dropped; pub mod component_events_timed_out; mod events_received; mod events_sent; +pub mod metric_name; mod optional_tag; mod prelude; pub mod service; @@ -16,6 +17,7 @@ pub use bytes_sent::BytesSent; #[allow(clippy::module_name_repetitions)] pub use cached_event::{RegisterTaggedInternalEvent, RegisteredEventCache}; pub use component_events_dropped::{ComponentEventsDropped, INTENTIONAL, UNINTENTIONAL}; +pub use metric_name::MetricName; pub use component_events_timed_out::ComponentEventsTimedOut; pub use events_received::{EventsReceived, EventsReceivedHandle}; pub use events_sent::{DEFAULT_OUTPUT, EventsSent, TaggedEventsSent}; diff --git a/lib/vector-common/src/internal_event/service.rs b/lib/vector-common/src/internal_event/service.rs index 93a3c9b745722..536899c2f356f 100644 --- a/lib/vector-common/src/internal_event/service.rs +++ b/lib/vector-common/src/internal_event/service.rs @@ -1,4 +1,6 @@ -use metrics::counter; +use super::MetricName; + +use crate::counter; use super::{ComponentEventsDropped, InternalEvent, UNINTENTIONAL, emit, error_stage, error_type}; use crate::NamedInternalEvent; @@ -17,7 +19,7 @@ impl InternalEvent for PollReadyError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::SENDING, ) @@ -43,7 +45,7 @@ impl InternalEvent for CallError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::SENDING, ) diff --git a/lib/vector-common/src/lib.rs b/lib/vector-common/src/lib.rs index 099a068578090..b577eb2bcc463 100644 --- a/lib/vector-common/src/lib.rs +++ b/lib/vector-common/src/lib.rs @@ -66,6 +66,67 @@ pub mod trigger; #[macro_use] extern crate tracing; +/// Typed wrapper around `metrics::counter!` that only accepts [`internal_event::MetricName`]. +/// +/// Prevents raw string literals from being used as metric names — all metric +/// names must go through the `MetricName` enum so they are discoverable and +/// exposable via the API. +#[macro_export] +macro_rules! counter { + ($name:expr) => {{ + let _name: $crate::internal_event::MetricName = $name; + #[allow(clippy::disallowed_macros)] + { + metrics::counter!(_name.as_str()) + } + }}; + ($name:expr, $($rest:tt)*) => {{ + let _name: $crate::internal_event::MetricName = $name; + #[allow(clippy::disallowed_macros)] + { + metrics::counter!(_name.as_str(), $($rest)*) + } + }}; +} + +/// Typed wrapper around `metrics::histogram!` that only accepts [`internal_event::MetricName`]. +#[macro_export] +macro_rules! histogram { + ($name:expr) => {{ + let _name: $crate::internal_event::MetricName = $name; + #[allow(clippy::disallowed_macros)] + { + metrics::histogram!(_name.as_str()) + } + }}; + ($name:expr, $($rest:tt)*) => {{ + let _name: $crate::internal_event::MetricName = $name; + #[allow(clippy::disallowed_macros)] + { + metrics::histogram!(_name.as_str(), $($rest)*) + } + }}; +} + +/// Typed wrapper around `metrics::gauge!` that only accepts [`internal_event::MetricName`]. +#[macro_export] +macro_rules! gauge { + ($name:expr) => {{ + let _name: $crate::internal_event::MetricName = $name; + #[allow(clippy::disallowed_macros)] + { + metrics::gauge!(_name.as_str()) + } + }}; + ($name:expr, $($rest:tt)*) => {{ + let _name: $crate::internal_event::MetricName = $name; + #[allow(clippy::disallowed_macros)] + { + metrics::gauge!(_name.as_str(), $($rest)*) + } + }}; +} + /// Vector's basic error type, dynamically dispatched and safe to send across /// threads. pub type Error = Box; From 914dd54252765435926982bc5633eb4ef03545dd Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 17:30:30 -0400 Subject: [PATCH 02/17] Use EventName in lib/ --- lib/codecs/src/internal_events.rs | 29 +++++----- lib/vector-buffers/src/internal_events.rs | 53 ++++++++++--------- .../src/topology/channel/limited_queue.rs | 1 + .../src/internal_event/cached_event.rs | 45 ++++++++-------- .../src/internal_event/metric_name.rs | 42 +++++++++++++++ lib/vector-core/src/latency.rs | 9 ++-- lib/vector-core/src/metrics/mod.rs | 45 +--------------- lib/vector-core/src/source_sender/builder.rs | 2 +- lib/vector-core/src/source_sender/mod.rs | 8 +-- lib/vector-core/src/source_sender/sender.rs | 2 +- 10 files changed, 121 insertions(+), 115 deletions(-) diff --git a/lib/codecs/src/internal_events.rs b/lib/codecs/src/internal_events.rs index d21119419887d..7547989140501 100644 --- a/lib/codecs/src/internal_events.rs +++ b/lib/codecs/src/internal_events.rs @@ -1,9 +1,12 @@ //! Internal events for codecs. -use metrics::counter; use tracing::error; -use vector_common::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, emit, error_stage, error_type, +use vector_common::{ + counter, + internal_event::{ + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, emit, error_stage, + error_type, + }, }; use vector_common_macros::NamedInternalEvent; @@ -24,7 +27,7 @@ impl InternalEvent for DecoderFramingError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "decoder_frame", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -50,7 +53,7 @@ impl InternalEvent for DecoderDeserializeError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "decoder_deserialize", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -77,7 +80,7 @@ impl InternalEvent for EncoderFramingError<'_> { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "encoder_frame", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -105,7 +108,7 @@ impl InternalEvent for EncoderSerializeError<'_> { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "encoder_serialize", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -137,7 +140,7 @@ impl InternalEvent for EncoderWriteError<'_, E> { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, ) @@ -170,7 +173,7 @@ impl InternalEvent for EncoderNullConstraintError<'_> { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "encoding_null_constraint", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -201,7 +204,7 @@ impl InternalEvent for EncoderRecordBatchError<'_, E> { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -228,7 +231,7 @@ impl InternalEvent for SchemaGenerationError<'_> { internal_log_rate_limit = false, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "parquet_schema_generation_failed", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -255,7 +258,7 @@ impl InternalEvent for ArrowWriterError<'_> { internal_log_rate_limit = false, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "parquet_arrow_writer_failed", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -281,7 +284,7 @@ impl InternalEvent for JsonSerializationError<'_> { internal_log_rate_limit = true, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, ) diff --git a/lib/vector-buffers/src/internal_events.rs b/lib/vector-buffers/src/internal_events.rs index 6d2735c7bb75f..a165c540f9121 100644 --- a/lib/vector-buffers/src/internal_events.rs +++ b/lib/vector-buffers/src/internal_events.rs @@ -1,9 +1,10 @@ use std::time::Duration; -use metrics::{Histogram, counter, gauge, histogram}; +use metrics::Histogram; use vector_common::NamedInternalEvent; use vector_common::{ - internal_event::{InternalEvent, error_type}, + counter, gauge, histogram, + internal_event::{InternalEvent, MetricName, error_type}, registered_event, }; @@ -21,14 +22,14 @@ impl InternalEvent for BufferCreated { let stage = self.idx.to_string(); if self.max_size_events != 0 { gauge!( - "buffer_max_size_events", + MetricName::BufferMaxSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => stage.clone(), ) .set(self.max_size_events as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_max_event_size", + MetricName::BufferMaxEventSize, "buffer_id" => self.buffer_id.clone(), "stage" => stage.clone(), ) @@ -36,14 +37,14 @@ impl InternalEvent for BufferCreated { } if self.max_size_bytes != 0 { gauge!( - "buffer_max_size_bytes", + MetricName::BufferMaxSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => stage.clone(), ) .set(self.max_size_bytes as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_max_byte_size", + MetricName::BufferMaxByteSize, "buffer_id" => self.buffer_id, "stage" => stage, ) @@ -66,40 +67,40 @@ impl InternalEvent for BufferEventsReceived { #[expect(clippy::cast_precision_loss)] fn emit(self) { counter!( - "buffer_received_events_total", + MetricName::BufferReceivedEventsTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.count); counter!( - "buffer_received_bytes_total", + MetricName::BufferReceivedBytesTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.byte_size); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_events", + MetricName::BufferEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - "buffer_size_events", + MetricName::BufferSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - "buffer_size_bytes", + MetricName::BufferSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_byte_size as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_byte_size", + MetricName::BufferByteSize, "buffer_id" => self.buffer_id, "stage" => self.idx.to_string() ) @@ -121,39 +122,39 @@ impl InternalEvent for BufferEventsSent { #[expect(clippy::cast_precision_loss)] fn emit(self) { counter!( - "buffer_sent_events_total", + MetricName::BufferSentEventsTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.count); counter!( - "buffer_sent_bytes_total", + MetricName::BufferSentBytesTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.byte_size); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_events", + MetricName::BufferEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - "buffer_size_events", + MetricName::BufferSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - "buffer_size_bytes", + MetricName::BufferSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_byte_size as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_byte_size", + MetricName::BufferByteSize, "buffer_id" => self.buffer_id, "stage" => self.idx.to_string() ) @@ -200,14 +201,14 @@ impl InternalEvent for BufferEventsDropped { } counter!( - "buffer_discarded_events_total", + MetricName::BufferDiscardedEventsTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string(), "intentional" => intentional_str, ) .increment(self.count); counter!( - "buffer_discarded_bytes_total", + MetricName::BufferDiscardedBytesTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string(), "intentional" => intentional_str, @@ -215,26 +216,26 @@ impl InternalEvent for BufferEventsDropped { .increment(self.byte_size); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_events", + MetricName::BufferEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - "buffer_size_events", + MetricName::BufferSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - "buffer_size_bytes", + MetricName::BufferSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_byte_size as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - "buffer_byte_size", + MetricName::BufferByteSize, "buffer_id" => self.buffer_id, "stage" => self.idx.to_string() ) @@ -258,7 +259,7 @@ impl InternalEvent for BufferReadError { stage = "processing", ); counter!( - "buffer_errors_total", "error_code" => self.error_code, + MetricName::BufferErrorsTotal, "error_code" => self.error_code, "error_type" => "reader_failed", "stage" => "processing", ) @@ -270,7 +271,7 @@ registered_event! { BufferSendDuration { stage: usize, } => { - send_duration: Histogram = histogram!("buffer_send_duration_seconds", "stage" => self.stage.to_string()), + send_duration: Histogram = histogram!(MetricName::BufferSendDurationSeconds, "stage" => self.stage.to_string()), } fn emit(&self, duration: Duration) { diff --git a/lib/vector-buffers/src/topology/channel/limited_queue.rs b/lib/vector-buffers/src/topology/channel/limited_queue.rs index a246aa9659812..3e1f3f7c98c93 100644 --- a/lib/vector-buffers/src/topology/channel/limited_queue.rs +++ b/lib/vector-buffers/src/topology/channel/limited_queue.rs @@ -127,6 +127,7 @@ struct Metrics { impl Metrics { #[expect(clippy::cast_precision_loss)] // We have to convert buffer sizes for a gauge, it's okay to lose precision here. + #[allow(clippy::disallowed_macros)] // Metric names are constructed dynamically from runtime prefixes. fn new( limit: MemoryBufferSize, metadata: ChannelMetricMetadata, diff --git a/lib/vector-common/src/internal_event/cached_event.rs b/lib/vector-common/src/internal_event/cached_event.rs index 782faeb5a1d01..14c3c778ae13e 100644 --- a/lib/vector-common/src/internal_event/cached_event.rs +++ b/lib/vector-common/src/internal_event/cached_event.rs @@ -95,30 +95,31 @@ mod tests { use super::*; - crate::registered_event!( - TestEvent { - fixed: String, - dynamic: String, - } => { - event: Counter = { - counter!("test_event_total", "fixed" => self.fixed, "dynamic" => self.dynamic) - }, - } - - fn emit(&self, count: u64) { - self.event.increment(count); - } - - fn register(fixed: String, dynamic: String) { - crate::internal_event::register(TestEvent { - fixed, - dynamic, - }) - } - ); - #[test] + #[allow(clippy::disallowed_macros)] fn test_fixed_tag() { + crate::registered_event!( + TestEvent { + fixed: String, + dynamic: String, + } => { + event: Counter = { + counter!("test_event_total", "fixed" => self.fixed, "dynamic" => self.dynamic) + }, + } + + fn emit(&self, count: u64) { + self.event.increment(count); + } + + fn register(fixed: String, dynamic: String) { + crate::internal_event::register(TestEvent { + fixed, + dynamic, + }) + } + ); + let event: RegisteredEventCache = RegisteredEventCache::new("fixed".to_string()); diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs index a9c7ed0f1de10..0182c881b6d96 100644 --- a/lib/vector-common/src/internal_event/metric_name.rs +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -15,6 +15,27 @@ pub enum MetricName { ComponentErrorsTotal, ComponentTimedOutEventsTotal, ComponentTimedOutRequestsTotal, + BufferMaxSizeEvents, + BufferMaxEventSize, + BufferMaxSizeBytes, + BufferMaxByteSize, + BufferReceivedEventsTotal, + BufferReceivedBytesTotal, + BufferSentEventsTotal, + BufferSentBytesTotal, + BufferDiscardedEventsTotal, + BufferDiscardedBytesTotal, + BufferErrorsTotal, + BufferSendDurationSeconds, + BufferEvents, + BufferSizeEvents, + BufferSizeBytes, + BufferByteSize, + ComponentLatencySeconds, + ComponentLatencyMeanSeconds, + SourceLagTimeSeconds, + SourceSendLatencySeconds, + SourceSendBatchLatencySeconds, } impl MetricName { @@ -32,6 +53,27 @@ impl MetricName { Self::ComponentErrorsTotal => "component_errors_total", Self::ComponentTimedOutEventsTotal => "component_timed_out_events_total", Self::ComponentTimedOutRequestsTotal => "component_timed_out_requests_total", + Self::BufferMaxSizeEvents => "buffer_max_size_events", + Self::BufferMaxEventSize => "buffer_max_event_size", + Self::BufferMaxSizeBytes => "buffer_max_size_bytes", + Self::BufferMaxByteSize => "buffer_max_byte_size", + Self::BufferReceivedEventsTotal => "buffer_received_events_total", + Self::BufferReceivedBytesTotal => "buffer_received_bytes_total", + Self::BufferSentEventsTotal => "buffer_sent_events_total", + Self::BufferSentBytesTotal => "buffer_sent_bytes_total", + Self::BufferDiscardedEventsTotal => "buffer_discarded_events_total", + Self::BufferDiscardedBytesTotal => "buffer_discarded_bytes_total", + Self::BufferErrorsTotal => "buffer_errors_total", + Self::BufferSendDurationSeconds => "buffer_send_duration_seconds", + Self::BufferEvents => "buffer_events", + Self::BufferSizeEvents => "buffer_size_events", + Self::BufferSizeBytes => "buffer_size_bytes", + Self::BufferByteSize => "buffer_byte_size", + Self::ComponentLatencySeconds => "component_latency_seconds", + Self::ComponentLatencyMeanSeconds => "component_latency_mean_seconds", + Self::SourceLagTimeSeconds => "source_lag_time_seconds", + Self::SourceSendLatencySeconds => "source_send_latency_seconds", + Self::SourceSendBatchLatencySeconds => "source_send_batch_latency_seconds", } } } diff --git a/lib/vector-core/src/latency.rs b/lib/vector-core/src/latency.rs index 536a8ef532d0d..70c04073e824e 100644 --- a/lib/vector-core/src/latency.rs +++ b/lib/vector-core/src/latency.rs @@ -1,12 +1,11 @@ use std::time::Instant; -use metrics::{Histogram, gauge, histogram}; +use metrics::Histogram; +use vector_common::{gauge, histogram, internal_event::MetricName}; use vector_common::stats::EwmaGauge; use crate::event::EventArray; -const COMPONENT_LATENCY: &str = "component_latency_seconds"; -const COMPONENT_LATENCY_MEAN: &str = "component_latency_mean_seconds"; const DEFAULT_LATENCY_EWMA_ALPHA: f64 = 0.9; #[derive(Debug)] @@ -18,9 +17,9 @@ pub struct LatencyRecorder { impl LatencyRecorder { pub fn new(ewma_alpha: Option) -> Self { Self { - histogram: histogram!(COMPONENT_LATENCY), + histogram: histogram!(MetricName::ComponentLatencySeconds), gauge: EwmaGauge::new( - gauge!(COMPONENT_LATENCY_MEAN), + gauge!(MetricName::ComponentLatencyMeanSeconds), ewma_alpha.or(Some(DEFAULT_LATENCY_EWMA_ALPHA)), ), } diff --git a/lib/vector-core/src/metrics/mod.rs b/lib/vector-core/src/metrics/mod.rs index 660f29c000db3..edc70f1615a5b 100644 --- a/lib/vector-core/src/metrics/mod.rs +++ b/lib/vector-core/src/metrics/mod.rs @@ -200,52 +200,9 @@ impl Controller { } } -#[macro_export] -/// This macro is used to emit metrics as a `counter` while simultaneously -/// converting from absolute values to incremental values. -/// -/// Values that do not arrive in strictly monotonically increasing order are -/// ignored and will not be emitted. -macro_rules! update_counter { - ($label:literal, $value:expr) => {{ - use ::std::sync::atomic::{AtomicU64, Ordering}; - - static PREVIOUS_VALUE: AtomicU64 = AtomicU64::new(0); - - let new_value = $value; - let mut previous_value = PREVIOUS_VALUE.load(Ordering::Relaxed); - - loop { - // Either a new greater value has been emitted before this thread updated the counter - // or values were provided that are not in strictly monotonically increasing order. - // Ignore. - if new_value <= previous_value { - break; - } - - match PREVIOUS_VALUE.compare_exchange_weak( - previous_value, - new_value, - Ordering::SeqCst, - Ordering::Relaxed, - ) { - // Another thread has written a new value before us. Re-enter loop. - Err(value) => previous_value = value, - // Calculate delta to last emitted value and emit it. - Ok(_) => { - let delta = new_value - previous_value; - // Albeit very unlikely, note that this sequence of deltas might be emitted in - // a different order than they were calculated. - counter!($label).increment(delta); - break; - } - } - } - }}; -} - #[cfg(test)] mod tests { + #![allow(clippy::disallowed_macros)] use super::*; use crate::{ config::metrics_expiration::{ diff --git a/lib/vector-core/src/source_sender/builder.rs b/lib/vector-core/src/source_sender/builder.rs index f3051726a7f56..ddaf9617d54a0 100644 --- a/lib/vector-core/src/source_sender/builder.rs +++ b/lib/vector-core/src/source_sender/builder.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, time::Duration}; -use metrics::histogram; +use vector_common::histogram; use vector_buffers::topology::channel::LimitedReceiver; use vector_common::internal_event::DEFAULT_OUTPUT; diff --git a/lib/vector-core/src/source_sender/mod.rs b/lib/vector-core/src/source_sender/mod.rs index fc0cb417890a0..c60cc0be4f8c3 100644 --- a/lib/vector-core/src/source_sender/mod.rs +++ b/lib/vector-core/src/source_sender/mod.rs @@ -22,6 +22,8 @@ pub const CHUNK_SIZE: usize = 1000; #[cfg(any(test, feature = "test"))] const TEST_BUFFER_SIZE: usize = 100; -const LAG_TIME_NAME: &str = "source_lag_time_seconds"; -const SEND_LATENCY_NAME: &str = "source_send_latency_seconds"; -const SEND_BATCH_LATENCY_NAME: &str = "source_send_batch_latency_seconds"; +use vector_common::internal_event::MetricName; + +const LAG_TIME_NAME: MetricName = MetricName::SourceLagTimeSeconds; +const SEND_LATENCY_NAME: MetricName = MetricName::SourceSendLatencySeconds; +const SEND_BATCH_LATENCY_NAME: MetricName = MetricName::SourceSendBatchLatencySeconds; diff --git a/lib/vector-core/src/source_sender/sender.rs b/lib/vector-core/src/source_sender/sender.rs index 6041dad3dad9f..50b6d5cf67f90 100644 --- a/lib/vector-core/src/source_sender/sender.rs +++ b/lib/vector-core/src/source_sender/sender.rs @@ -6,7 +6,7 @@ use futures::Stream; #[cfg(any(test, feature = "test"))] use futures::StreamExt as _; #[cfg(any(test, feature = "test"))] -use metrics::histogram; +use vector_common::histogram; use vector_buffers::EventCount; #[cfg(any(test, feature = "test"))] use vector_buffers::topology::channel::LimitedReceiver; From 61799f83532dcb4dba5a729d1189955df1b6ddce Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 18:06:06 -0400 Subject: [PATCH 03/17] Use MetricName in src/internal_events --- .../src/internal_event/metric_name.rs | 183 ++++++++++++++++++ src/internal_events/adaptive_concurrency.rs | 17 +- src/internal_events/aggregate.rs | 8 +- src/internal_events/amqp.rs | 10 +- src/internal_events/apache_metrics.rs | 8 +- src/internal_events/api.rs | 4 +- src/internal_events/aws.rs | 4 +- src/internal_events/aws_cloudwatch_logs.rs | 4 +- src/internal_events/aws_ec2_metadata.rs | 8 +- src/internal_events/aws_ecs_metrics.rs | 10 +- src/internal_events/aws_kinesis.rs | 4 +- src/internal_events/aws_kinesis_firehose.rs | 6 +- src/internal_events/aws_sqs.rs | 30 +-- src/internal_events/batch.rs | 4 +- src/internal_events/common.rs | 16 +- src/internal_events/conditions.rs | 4 +- src/internal_events/datadog_agent.rs | 4 +- src/internal_events/datadog_metrics.rs | 4 +- src/internal_events/datadog_traces.rs | 6 +- src/internal_events/dnstap.rs | 4 +- src/internal_events/docker_logs.rs | 20 +- src/internal_events/doris.rs | 8 +- src/internal_events/encoding_transcode.rs | 8 +- src/internal_events/eventstoredb_metrics.rs | 6 +- src/internal_events/exec.rs | 18 +- src/internal_events/expansion.rs | 4 +- src/internal_events/file.rs | 64 +++--- src/internal_events/file_descriptor.rs | 4 +- src/internal_events/fluent.rs | 4 +- src/internal_events/gcp_pubsub.rs | 8 +- src/internal_events/grpc.rs | 12 +- src/internal_events/heartbeat.rs | 6 +- src/internal_events/host_metrics.rs | 8 +- src/internal_events/http.rs | 22 +-- src/internal_events/http_client.rs | 17 +- src/internal_events/http_client_source.rs | 10 +- src/internal_events/influxdb.rs | 4 +- src/internal_events/internal_logs.rs | 9 +- src/internal_events/journald.rs | 12 +- src/internal_events/kafka.rs | 36 ++-- src/internal_events/kubernetes_logs.rs | 22 +-- src/internal_events/log_to_metric.rs | 12 +- src/internal_events/logplex.rs | 4 +- src/internal_events/loki.rs | 10 +- src/internal_events/lua.rs | 8 +- src/internal_events/metric_to_log.rs | 4 +- src/internal_events/mongodb_metrics.rs | 10 +- src/internal_events/mqtt.rs | 4 +- src/internal_events/nginx_metrics.rs | 10 +- src/internal_events/open.rs | 6 +- src/internal_events/parser.rs | 8 +- src/internal_events/postgresql_metrics.rs | 4 +- src/internal_events/process.rs | 16 +- src/internal_events/prometheus.rs | 8 +- src/internal_events/pulsar.rs | 12 +- src/internal_events/redis.rs | 4 +- src/internal_events/reduce.rs | 6 +- src/internal_events/remap.rs | 4 +- src/internal_events/sematext_metrics.rs | 6 +- src/internal_events/socket.rs | 29 +-- src/internal_events/splunk_hec.rs | 24 +-- src/internal_events/statsd_sink.rs | 4 +- src/internal_events/tag_cardinality_limit.rs | 12 +- src/internal_events/tcp.rs | 14 +- src/internal_events/template.rs | 4 +- src/internal_events/throttle.rs | 4 +- src/internal_events/udp.rs | 10 +- src/internal_events/unix.rs | 12 +- src/internal_events/websocket.rs | 22 +-- src/internal_events/websocket_server.rs | 18 +- src/internal_events/windows.rs | 14 +- src/internal_events/windows_event_log.rs | 8 +- 72 files changed, 571 insertions(+), 380 deletions(-) diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs index 0182c881b6d96..93879c2fcb180 100644 --- a/lib/vector-common/src/internal_event/metric_name.rs +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -36,6 +36,96 @@ pub enum MetricName { SourceLagTimeSeconds, SourceSendLatencySeconds, SourceSendBatchLatencySeconds, + // Internal events from src/internal_events/ + ActiveClients, + ActiveEndpoints, + AdaptiveConcurrencyAveragedRtt, + AdaptiveConcurrencyBackPressure, + AdaptiveConcurrencyInFlight, + AdaptiveConcurrencyLimit, + AdaptiveConcurrencyObservedRtt, + AdaptiveConcurrencyPastRttMean, + AdaptiveConcurrencyReachedLimit, + AggregateEventsRecordedTotal, + AggregateFailedUpdates, + AggregateFlushesTotal, + ApiStartedTotal, + BuildInfo, + CheckpointsTotal, + ChecksumErrorsTotal, + CollectCompletedTotal, + CollectDurationSeconds, + CommandExecutedTotal, + CommandExecutionDurationSeconds, + ComponentReceivedBytes, + ConnectionEstablishedTotal, + ConnectionSendErrorsTotal, + ConnectionShutdownTotal, + ContainerProcessedEventsTotal, + ContainersUnwatchedTotal, + ContainersWatchedTotal, + DecoderBomRemovalsTotal, + DecoderMalformedReplacementWarningsTotal, + DorisBytesLoadedTotal, + DorisRowsFilteredTotal, + DorisRowsLoadedTotal, + EncoderUnmappableReplacementWarningsTotal, + EventsDiscardedTotal, + FilesAddedTotal, + FilesDeletedTotal, + FilesResumedTotal, + FilesUnwatchedTotal, + GrpcServerHandlerDurationSeconds, + GrpcServerMessagesReceivedTotal, + GrpcServerMessagesSentTotal, + HttpClientErrorRttSeconds, + HttpClientErrorsTotal, + HttpClientRequestsSentTotal, + HttpClientResponseRttSeconds, + HttpClientResponsesTotal, + HttpClientRttSeconds, + HttpServerHandlerDurationSeconds, + HttpServerRequestsReceivedTotal, + HttpServerResponsesSentTotal, + KafkaConsumedMessagesBytesTotal, + KafkaConsumedMessagesTotal, + KafkaConsumerLag, + KafkaProducedMessagesBytesTotal, + KafkaProducedMessagesTotal, + KafkaQueueMessages, + KafkaQueueMessagesBytes, + KafkaRequestsBytesTotal, + KafkaRequestsTotal, + KafkaResponsesBytesTotal, + KafkaResponsesTotal, + LuaMemoryUsedBytes, + MetadataRefreshFailedTotal, + MetadataRefreshSuccessfulTotal, + OpenConnections, + OpenFiles, + ParseErrorsTotal, + QuitTotal, + ReloadedTotal, + RewrittenTimestampEventsTotal, + SplunkPendingAcks, + SqsMessageDeferSucceededTotal, + SqsMessageDeleteSucceededTotal, + SqsMessageProcessingSucceededTotal, + SqsMessageReceiveSucceededTotal, + SqsMessageReceivedMessagesTotal, + StaleEventsFlushedTotal, + StartedTotal, + StoppedTotal, + TagValueLimitExceededTotal, + UptimeSeconds, + ValueLimitReachedTotal, + WebsocketBytesSentTotal, + WebsocketMessagesSentTotal, + WindowsServiceInstallTotal, + WindowsServiceRestartTotal, + WindowsServiceStartTotal, + WindowsServiceStopTotal, + WindowsServiceUninstallTotal, } impl MetricName { @@ -74,6 +164,99 @@ impl MetricName { Self::SourceLagTimeSeconds => "source_lag_time_seconds", Self::SourceSendLatencySeconds => "source_send_latency_seconds", Self::SourceSendBatchLatencySeconds => "source_send_batch_latency_seconds", + Self::ActiveClients => "active_clients", + Self::ActiveEndpoints => "active_endpoints", + Self::AdaptiveConcurrencyAveragedRtt => "adaptive_concurrency_averaged_rtt", + Self::AdaptiveConcurrencyBackPressure => "adaptive_concurrency_back_pressure", + Self::AdaptiveConcurrencyInFlight => "adaptive_concurrency_in_flight", + Self::AdaptiveConcurrencyLimit => "adaptive_concurrency_limit", + Self::AdaptiveConcurrencyObservedRtt => "adaptive_concurrency_observed_rtt", + Self::AdaptiveConcurrencyPastRttMean => "adaptive_concurrency_past_rtt_mean", + Self::AdaptiveConcurrencyReachedLimit => "adaptive_concurrency_reached_limit", + Self::AggregateEventsRecordedTotal => "aggregate_events_recorded_total", + Self::AggregateFailedUpdates => "aggregate_failed_updates", + Self::AggregateFlushesTotal => "aggregate_flushes_total", + Self::ApiStartedTotal => "api_started_total", + Self::BuildInfo => "build_info", + Self::CheckpointsTotal => "checkpoints_total", + Self::ChecksumErrorsTotal => "checksum_errors_total", + Self::CollectCompletedTotal => "collect_completed_total", + Self::CollectDurationSeconds => "collect_duration_seconds", + Self::CommandExecutedTotal => "command_executed_total", + Self::CommandExecutionDurationSeconds => "command_execution_duration_seconds", + Self::ComponentReceivedBytes => "component_received_bytes", + Self::ConnectionEstablishedTotal => "connection_established_total", + Self::ConnectionSendErrorsTotal => "connection_send_errors_total", + Self::ConnectionShutdownTotal => "connection_shutdown_total", + Self::ContainerProcessedEventsTotal => "container_processed_events_total", + Self::ContainersUnwatchedTotal => "containers_unwatched_total", + Self::ContainersWatchedTotal => "containers_watched_total", + Self::DecoderBomRemovalsTotal => "decoder_bom_removals_total", + Self::DecoderMalformedReplacementWarningsTotal => { + "decoder_malformed_replacement_warnings_total" + } + Self::DorisBytesLoadedTotal => "doris_bytes_loaded_total", + Self::DorisRowsFilteredTotal => "doris_rows_filtered_total", + Self::DorisRowsLoadedTotal => "doris_rows_loaded_total", + Self::EncoderUnmappableReplacementWarningsTotal => { + "encoder_unmappable_replacement_warnings_total" + } + Self::EventsDiscardedTotal => "events_discarded_total", + Self::FilesAddedTotal => "files_added_total", + Self::FilesDeletedTotal => "files_deleted_total", + Self::FilesResumedTotal => "files_resumed_total", + Self::FilesUnwatchedTotal => "files_unwatched_total", + Self::GrpcServerHandlerDurationSeconds => "grpc_server_handler_duration_seconds", + Self::GrpcServerMessagesReceivedTotal => "grpc_server_messages_received_total", + Self::GrpcServerMessagesSentTotal => "grpc_server_messages_sent_total", + Self::HttpClientErrorRttSeconds => "http_client_error_rtt_seconds", + Self::HttpClientErrorsTotal => "http_client_errors_total", + Self::HttpClientRequestsSentTotal => "http_client_requests_sent_total", + Self::HttpClientResponseRttSeconds => "http_client_response_rtt_seconds", + Self::HttpClientResponsesTotal => "http_client_responses_total", + Self::HttpClientRttSeconds => "http_client_rtt_seconds", + Self::HttpServerHandlerDurationSeconds => "http_server_handler_duration_seconds", + Self::HttpServerRequestsReceivedTotal => "http_server_requests_received_total", + Self::HttpServerResponsesSentTotal => "http_server_responses_sent_total", + Self::KafkaConsumedMessagesBytesTotal => "kafka_consumed_messages_bytes_total", + Self::KafkaConsumedMessagesTotal => "kafka_consumed_messages_total", + Self::KafkaConsumerLag => "kafka_consumer_lag", + Self::KafkaProducedMessagesBytesTotal => "kafka_produced_messages_bytes_total", + Self::KafkaProducedMessagesTotal => "kafka_produced_messages_total", + Self::KafkaQueueMessages => "kafka_queue_messages", + Self::KafkaQueueMessagesBytes => "kafka_queue_messages_bytes", + Self::KafkaRequestsBytesTotal => "kafka_requests_bytes_total", + Self::KafkaRequestsTotal => "kafka_requests_total", + Self::KafkaResponsesBytesTotal => "kafka_responses_bytes_total", + Self::KafkaResponsesTotal => "kafka_responses_total", + Self::LuaMemoryUsedBytes => "lua_memory_used_bytes", + Self::MetadataRefreshFailedTotal => "metadata_refresh_failed_total", + Self::MetadataRefreshSuccessfulTotal => "metadata_refresh_successful_total", + Self::OpenConnections => "open_connections", + Self::OpenFiles => "open_files", + Self::ParseErrorsTotal => "parse_errors_total", + Self::QuitTotal => "quit_total", + Self::ReloadedTotal => "reloaded_total", + Self::RewrittenTimestampEventsTotal => "rewritten_timestamp_events_total", + Self::SplunkPendingAcks => "splunk_pending_acks", + Self::SqsMessageDeferSucceededTotal => "sqs_message_defer_succeeded_total", + Self::SqsMessageDeleteSucceededTotal => "sqs_message_delete_succeeded_total", + Self::SqsMessageProcessingSucceededTotal => "sqs_message_processing_succeeded_total", + Self::SqsMessageReceiveSucceededTotal => "sqs_message_receive_succeeded_total", + Self::SqsMessageReceivedMessagesTotal => "sqs_message_received_messages_total", + Self::StaleEventsFlushedTotal => "stale_events_flushed_total", + Self::StartedTotal => "started_total", + Self::StoppedTotal => "stopped_total", + Self::TagValueLimitExceededTotal => "tag_value_limit_exceeded_total", + Self::UptimeSeconds => "uptime_seconds", + Self::ValueLimitReachedTotal => "value_limit_reached_total", + Self::WebsocketBytesSentTotal => "websocket_bytes_sent_total", + Self::WebsocketMessagesSentTotal => "websocket_messages_sent_total", + Self::WindowsServiceInstallTotal => "windows_service_install_total", + Self::WindowsServiceRestartTotal => "windows_service_restart_total", + Self::WindowsServiceStartTotal => "windows_service_start_total", + Self::WindowsServiceStopTotal => "windows_service_stop_total", + Self::WindowsServiceUninstallTotal => "windows_service_uninstall_total", } } } diff --git a/src/internal_events/adaptive_concurrency.rs b/src/internal_events/adaptive_concurrency.rs index f815f7d4e2b4b..2aeb9692a9a58 100644 --- a/src/internal_events/adaptive_concurrency.rs +++ b/src/internal_events/adaptive_concurrency.rs @@ -1,6 +1,7 @@ use std::time::Duration; -use metrics::{Histogram, histogram}; +use metrics::Histogram; +use vector_common::histogram; #[derive(Clone, Copy)] pub struct AdaptiveConcurrencyLimitData { @@ -17,10 +18,10 @@ registered_event! { // These are histograms, as they may have a number of different // values over each reporting interval, and each of those values // is valuable for diagnosis. - limit: Histogram = histogram!("adaptive_concurrency_limit"), - reached_limit: Histogram = histogram!("adaptive_concurrency_reached_limit"), - back_pressure: Histogram = histogram!("adaptive_concurrency_back_pressure"), - past_rtt_mean: Histogram = histogram!("adaptive_concurrency_past_rtt_mean"), + limit: Histogram = histogram!(MetricName::AdaptiveConcurrencyLimit), + reached_limit: Histogram = histogram!(MetricName::AdaptiveConcurrencyReachedLimit), + back_pressure: Histogram = histogram!(MetricName::AdaptiveConcurrencyBackPressure), + past_rtt_mean: Histogram = histogram!(MetricName::AdaptiveConcurrencyPastRttMean), } fn emit(&self, data: AdaptiveConcurrencyLimitData) { @@ -36,7 +37,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyInFlight => { - in_flight: Histogram = histogram!("adaptive_concurrency_in_flight"), + in_flight: Histogram = histogram!(MetricName::AdaptiveConcurrencyInFlight), } fn emit(&self, in_flight: u64) { @@ -46,7 +47,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyObservedRtt => { - observed_rtt: Histogram = histogram!("adaptive_concurrency_observed_rtt"), + observed_rtt: Histogram = histogram!(MetricName::AdaptiveConcurrencyObservedRtt), } fn emit(&self, rtt: Duration) { @@ -56,7 +57,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyAveragedRtt => { - averaged_rtt: Histogram = histogram!("adaptive_concurrency_averaged_rtt"), + averaged_rtt: Histogram = histogram!(MetricName::AdaptiveConcurrencyAveragedRtt), } fn emit(&self, rtt: Duration) { diff --git a/src/internal_events/aggregate.rs b/src/internal_events/aggregate.rs index 1b70c4350f614..7e36a2f85abb9 100644 --- a/src/internal_events/aggregate.rs +++ b/src/internal_events/aggregate.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::InternalEvent; @@ -7,7 +7,7 @@ pub struct AggregateEventRecorded; impl InternalEvent for AggregateEventRecorded { fn emit(self) { - counter!("aggregate_events_recorded_total").increment(1); + counter!(MetricName::AggregateEventsRecordedTotal).increment(1); } } @@ -16,7 +16,7 @@ pub struct AggregateFlushed; impl InternalEvent for AggregateFlushed { fn emit(self) { - counter!("aggregate_flushes_total").increment(1); + counter!(MetricName::AggregateFlushesTotal).increment(1); } } @@ -25,6 +25,6 @@ pub struct AggregateUpdateFailed; impl InternalEvent for AggregateUpdateFailed { fn emit(self) { - counter!("aggregate_failed_updates").increment(1); + counter!(MetricName::AggregateFailedUpdates).increment(1); } } diff --git a/src/internal_events/amqp.rs b/src/internal_events/amqp.rs index 45acdf201305a..3e7891a8d1381 100644 --- a/src/internal_events/amqp.rs +++ b/src/internal_events/amqp.rs @@ -1,6 +1,6 @@ #[cfg(feature = "sources-amqp")] pub mod source { - use metrics::counter; + use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -18,7 +18,7 @@ pub mod source { protocol = %self.protocol, ); counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "protocol" => self.protocol, ) .increment(self.byte_size as u64); @@ -38,7 +38,7 @@ pub mod source { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) @@ -59,7 +59,7 @@ pub mod source { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::RECEIVING, ) @@ -80,7 +80,7 @@ pub mod source { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/apache_metrics.rs b/src/internal_events/apache_metrics.rs index dd5e9c34e4cf5..624c03772bbfb 100644 --- a/src/internal_events/apache_metrics.rs +++ b/src/internal_events/apache_metrics.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -19,12 +19,12 @@ impl InternalEvent for ApacheMetricsEventsReceived<'_> { fn emit(self) { trace!(message = "Events received.", count = %self.count, byte_size = %self.byte_size, endpoint = %self.endpoint); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -47,7 +47,7 @@ impl InternalEvent for ApacheMetricsParseError<'_> { endpoint = %self.endpoint, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, "endpoint" => self.endpoint.to_owned(), diff --git a/src/internal_events/api.rs b/src/internal_events/api.rs index de2cb9588537d..ae6cf5a2de147 100644 --- a/src/internal_events/api.rs +++ b/src/internal_events/api.rs @@ -1,6 +1,6 @@ use std::net::SocketAddr; -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::InternalEvent; @@ -15,6 +15,6 @@ impl InternalEvent for ApiStarted { message = "API server running.", address = %self.addr, ); - counter!("api_started_total").increment(1); + counter!(MetricName::ApiStartedTotal).increment(1); } } diff --git a/src/internal_events/aws.rs b/src/internal_events/aws.rs index ff4da6c01e56b..569171b447dc6 100644 --- a/src/internal_events/aws.rs +++ b/src/internal_events/aws.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::InternalEvent; @@ -21,7 +21,7 @@ impl InternalEvent for AwsBytesSent { region = ?self.region, ); counter!( - "component_sent_bytes_total", + MetricName::ComponentSentBytesTotal, "protocol" => "https", "region" => region, ) diff --git a/src/internal_events/aws_cloudwatch_logs.rs b/src/internal_events/aws_cloudwatch_logs.rs index 6325d6c71b25d..fe2b9345d7d61 100644 --- a/src/internal_events/aws_cloudwatch_logs.rs +++ b/src/internal_events/aws_cloudwatch_logs.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -22,7 +22,7 @@ impl InternalEvent for AwsCloudwatchLogsMessageSizeError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "message_too_long", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/aws_ec2_metadata.rs b/src/internal_events/aws_ec2_metadata.rs index 43c28aee61272..9351efb8b3677 100644 --- a/src/internal_events/aws_ec2_metadata.rs +++ b/src/internal_events/aws_ec2_metadata.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -8,7 +8,7 @@ pub struct AwsEc2MetadataRefreshSuccessful; impl InternalEvent for AwsEc2MetadataRefreshSuccessful { fn emit(self) { debug!(message = "AWS EC2 metadata refreshed."); - counter!("metadata_refresh_successful_total").increment(1); + counter!(MetricName::MetadataRefreshSuccessfulTotal).increment(1); } } @@ -26,12 +26,12 @@ impl InternalEvent for AwsEc2MetadataRefreshError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::PROCESSING, ) .increment(1); // deprecated - counter!("metadata_refresh_failed_total").increment(1); + counter!(MetricName::MetadataRefreshFailedTotal).increment(1); } } diff --git a/src/internal_events/aws_ecs_metrics.rs b/src/internal_events/aws_ecs_metrics.rs index 86b0d32012713..c50a096f66e11 100644 --- a/src/internal_events/aws_ecs_metrics.rs +++ b/src/internal_events/aws_ecs_metrics.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use metrics::counter; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -24,12 +24,12 @@ impl InternalEvent for AwsEcsMetricsEventsReceived<'_> { endpoint = %self.endpoint, ); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_string(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_string(), ) .increment(self.byte_size.get() as u64); @@ -57,9 +57,9 @@ impl InternalEvent for AwsEcsMetricsParseError<'_> { endpoint = %self.endpoint, "Failed to parse response.", ); - counter!("parse_errors_total").increment(1); + counter!(MetricName::ParseErrorsTotal).increment(1); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, "endpoint" => self.endpoint.to_string(), diff --git a/src/internal_events/aws_kinesis.rs b/src/internal_events/aws_kinesis.rs index 9fa2fb4315118..0d0f71bfa0a07 100644 --- a/src/internal_events/aws_kinesis.rs +++ b/src/internal_events/aws_kinesis.rs @@ -1,5 +1,5 @@ /// Used in both `aws_kinesis_streams` and `aws_kinesis_firehose` sinks -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -22,7 +22,7 @@ impl InternalEvent for AwsKinesisStreamNoPartitionKeyError<'_> { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/aws_kinesis_firehose.rs b/src/internal_events/aws_kinesis_firehose.rs index 6cb4ae43ea51f..1edb3d1baa3aa 100644 --- a/src/internal_events/aws_kinesis_firehose.rs +++ b/src/internal_events/aws_kinesis_firehose.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -49,7 +49,7 @@ impl InternalEvent for AwsKinesisFirehoseRequestError<'_> { request_id = %self.request_id.unwrap_or(""), ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::REQUEST_FAILED, "error_code" => self.error_code, @@ -75,7 +75,7 @@ impl InternalEvent for AwsKinesisFirehoseAutomaticRecordDecodeError { compression = %self.compression, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, "error_code" => io_error_code(&self.error), diff --git a/src/internal_events/aws_sqs.rs b/src/internal_events/aws_sqs.rs index 4bdcc8ef48e6c..e98696c717c6c 100644 --- a/src/internal_events/aws_sqs.rs +++ b/src/internal_events/aws_sqs.rs @@ -1,8 +1,8 @@ #![allow(dead_code)] // TODO requires optional feature compilation -use metrics::counter; #[cfg(feature = "sources-aws_s3")] pub use s3::*; +use vector_common::counter; #[cfg(any(feature = "sources-aws_s3", feature = "sources-aws_sqs"))] use vector_lib::internal_event::{error_stage, error_type}; use vector_lib::{NamedInternalEvent, internal_event::InternalEvent}; @@ -15,7 +15,7 @@ mod s3 { BatchResultErrorEntry, DeleteMessageBatchRequestEntry, DeleteMessageBatchResultEntry, SendMessageBatchRequestEntry, SendMessageBatchResultEntry, }; - use metrics::histogram; + use vector_common::histogram; use super::*; use crate::sources::aws_s3::sqs::ProcessingError; @@ -79,7 +79,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_processing_sqs_message", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -100,7 +100,8 @@ mod s3 { .map(|x| x.id.as_str()) .collect::>() .join(", ")); - counter!("sqs_message_delete_succeeded_total").increment(self.message_ids.len() as u64); + counter!(MetricName::SqsMessageDeleteSucceededTotal) + .increment(self.message_ids.len() as u64); } } @@ -122,7 +123,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_deleting_some_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -151,7 +152,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_deleting_all_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -172,7 +173,8 @@ mod s3 { .map(|x| x.id.as_str()) .collect::>() .join(", ")); - counter!("sqs_message_defer_succeeded_total").increment(self.message_ids.len() as u64); + counter!(MetricName::SqsMessageDeferSucceededTotal) + .increment(self.message_ids.len() as u64); } } @@ -194,7 +196,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_deferring_some_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -223,7 +225,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_deferring_all_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -248,7 +250,7 @@ impl InternalEvent for SqsMessageReceiveError<'_, E> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_fetching_sqs_events", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -265,8 +267,8 @@ pub struct SqsMessageReceiveSucceeded { impl InternalEvent for SqsMessageReceiveSucceeded { fn emit(self) { trace!(message = "Received SQS messages.", count = %self.count); - counter!("sqs_message_receive_succeeded_total").increment(1); - counter!("sqs_message_received_messages_total").increment(self.count as u64); + counter!(MetricName::SqsMessageReceiveSucceededTotal).increment(1); + counter!(MetricName::SqsMessageReceivedMessagesTotal).increment(self.count as u64); } } @@ -278,7 +280,7 @@ pub struct SqsMessageProcessingSucceeded<'a> { impl InternalEvent for SqsMessageProcessingSucceeded<'_> { fn emit(self) { trace!(message = "Processed SQS message successfully.", message_id = %self.message_id); - counter!("sqs_message_processing_succeeded_total").increment(1); + counter!(MetricName::SqsMessageProcessingSucceededTotal).increment(1); } } @@ -300,7 +302,7 @@ impl InternalEvent for SqsMessageDeleteError<'_, E> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/batch.rs b/src/internal_events/batch.rs index 8b7a4decfa770..8eb004c6ee3f7 100644 --- a/src/internal_events/batch.rs +++ b/src/internal_events/batch.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -21,7 +21,7 @@ impl InternalEvent for LargeEventDroppedError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "oversized", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::SENDING, diff --git a/src/internal_events/common.rs b/src/internal_events/common.rs index 69877e3db9ef5..8254c15eb8c86 100644 --- a/src/internal_events/common.rs +++ b/src/internal_events/common.rs @@ -1,6 +1,6 @@ use std::time::Instant; -use metrics::{counter, histogram}; +use vector_common::{counter, histogram}; use vector_lib::NamedInternalEvent; pub use vector_lib::internal_event::EventsReceived; use vector_lib::internal_event::{ @@ -23,7 +23,7 @@ impl InternalEvent for EndpointBytesReceived<'_> { endpoint = %self.endpoint, ); counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "protocol" => self.protocol.to_owned(), "endpoint" => self.endpoint.to_owned(), ) @@ -47,7 +47,7 @@ impl InternalEvent for EndpointBytesSent<'_> { endpoint = %self.endpoint ); counter!( - "component_sent_bytes_total", + MetricName::ComponentSentBytesTotal, "protocol" => self.protocol.to_string(), "endpoint" => self.endpoint.to_string() ) @@ -70,7 +70,7 @@ impl InternalEvent for SocketOutgoingConnectionError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_connecting", "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::SENDING, @@ -95,7 +95,7 @@ impl InternalEvent for StreamClosedError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => STREAM_CLOSED, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -117,8 +117,8 @@ pub struct CollectionCompleted { impl InternalEvent for CollectionCompleted { fn emit(self) { debug!(message = "Collection completed."); - counter!("collect_completed_total").increment(1); - histogram!("collect_duration_seconds").record(self.end - self.start); + counter!(MetricName::CollectCompletedTotal).increment(1); + histogram!(MetricName::CollectDurationSeconds).record(self.end - self.start); } } @@ -139,7 +139,7 @@ impl InternalEvent for SinkRequestBuildError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/conditions.rs b/src/internal_events/conditions.rs index 96f7ae0ae0d50..f41acca5fb8c7 100644 --- a/src/internal_events/conditions.rs +++ b/src/internal_events/conditions.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -16,7 +16,7 @@ impl InternalEvent for VrlConditionExecutionError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::SCRIPT_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/datadog_agent.rs b/src/internal_events/datadog_agent.rs index 9ee5296407b24..80d84b94ab325 100644 --- a/src/internal_events/datadog_agent.rs +++ b/src/internal_events/datadog_agent.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -16,7 +16,7 @@ impl InternalEvent for DatadogAgentJsonParseError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/datadog_metrics.rs b/src/internal_events/datadog_metrics.rs index 5daa3ab87fa79..8e01ef3ab36aa 100644 --- a/src/internal_events/datadog_metrics.rs +++ b/src/internal_events/datadog_metrics.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -21,7 +21,7 @@ impl InternalEvent for DatadogMetricsEncodingError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/datadog_traces.rs b/src/internal_events/datadog_traces.rs index 06b48552fb840..29bf957334c11 100644 --- a/src/internal_events/datadog_traces.rs +++ b/src/internal_events/datadog_traces.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -22,7 +22,7 @@ impl InternalEvent for DatadogTracesEncodingError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) @@ -51,7 +51,7 @@ impl InternalEvent for DatadogTracesAPMStatsError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) diff --git a/src/internal_events/dnstap.rs b/src/internal_events/dnstap.rs index 2fc20b95848d1..1870280ce5f7b 100644 --- a/src/internal_events/dnstap.rs +++ b/src/internal_events/dnstap.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -16,7 +16,7 @@ impl InternalEvent for DnstapParseError { error_type = error_type::PARSER_FAILED, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, ) diff --git a/src/internal_events/docker_logs.rs b/src/internal_events/docker_logs.rs index bb44e112e05b8..85ec380c30404 100644 --- a/src/internal_events/docker_logs.rs +++ b/src/internal_events/docker_logs.rs @@ -1,6 +1,6 @@ use bollard::errors::Error; use chrono::ParseError; -use metrics::counter; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -23,11 +23,11 @@ impl InternalEvent for DockerLogsEventsReceived<'_> { container_id = %self.container_id ); counter!( - "component_received_events_total", "container_name" => self.container_name.to_owned() + MetricName::ComponentReceivedEventsTotal, "container_name" => self.container_name.to_owned() ) .increment(1); counter!( - "component_received_event_bytes_total", "container_name" => self.container_name.to_owned() + MetricName::ComponentReceivedEventBytesTotal, "container_name" => self.container_name.to_owned() ).increment(self.byte_size.get() as u64); } } @@ -45,7 +45,7 @@ impl InternalEvent for DockerLogsContainerEventReceived<'_> { container_id = %self.container_id, action = %self.action, ); - counter!("container_processed_events_total").increment(1); + counter!(MetricName::ContainerProcessedEventsTotal).increment(1); } } @@ -60,7 +60,7 @@ impl InternalEvent for DockerLogsContainerWatch<'_> { message = "Started watching for container logs.", container_id = %self.container_id, ); - counter!("containers_watched_total").increment(1); + counter!(MetricName::ContainersWatchedTotal).increment(1); } } @@ -75,7 +75,7 @@ impl InternalEvent for DockerLogsContainerUnwatch<'_> { message = "Stopped watching for container logs.", container_id = %self.container_id, ); - counter!("containers_unwatched_total").increment(1); + counter!(MetricName::ContainersUnwatchedTotal).increment(1); } } @@ -95,7 +95,7 @@ impl InternalEvent for DockerLogsCommunicationError<'_> { container_id = ?self.container_id ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, ) @@ -119,7 +119,7 @@ impl InternalEvent for DockerLogsContainerMetadataFetchError<'_> { container_id = ?self.container_id ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, "container_id" => self.container_id.to_owned(), @@ -144,7 +144,7 @@ impl InternalEvent for DockerLogsTimestampParseError<'_> { container_id = ?self.container_id ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, "container_id" => self.container_id.to_owned(), @@ -169,7 +169,7 @@ impl InternalEvent for DockerLogsLoggingDriverUnsupportedError<'_> { container_id = ?self.container_id, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::RECEIVING, "container_id" => self.container_id.to_owned(), diff --git a/src/internal_events/doris.rs b/src/internal_events/doris.rs index 0a2430869b7c5..142a38e3343c8 100644 --- a/src/internal_events/doris.rs +++ b/src/internal_events/doris.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::{NamedInternalEvent, internal_event::InternalEvent}; /// Emitted when rows are successfully loaded into Doris. @@ -17,10 +17,10 @@ impl InternalEvent for DorisRowsLoaded { ); // Record the number of rows loaded - counter!("doris_rows_loaded_total").increment(self.loaded_rows as u64); + counter!(MetricName::DorisRowsLoadedTotal).increment(self.loaded_rows as u64); // Record the number of bytes loaded - counter!("doris_bytes_loaded_total").increment(self.load_bytes as u64); + counter!(MetricName::DorisBytesLoadedTotal).increment(self.load_bytes as u64); } } @@ -37,6 +37,6 @@ impl InternalEvent for DorisRowsFiltered { filtered_rows = %self.filtered_rows ); - counter!("doris_rows_filtered_total").increment(self.filtered_rows as u64); + counter!(MetricName::DorisRowsFilteredTotal).increment(self.filtered_rows as u64); } } diff --git a/src/internal_events/encoding_transcode.rs b/src/internal_events/encoding_transcode.rs index 76ad81792a63a..91b969074cfd6 100644 --- a/src/internal_events/encoding_transcode.rs +++ b/src/internal_events/encoding_transcode.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::InternalEvent; @@ -13,7 +13,7 @@ impl InternalEvent for DecoderBomRemoval { message = "Removing initial BOM bytes from the final output while decoding to utf8.", from_encoding = %self.from_encoding ); - counter!("decoder_bom_removals_total").increment(1); + counter!(MetricName::DecoderBomRemovalsTotal).increment(1); } } @@ -30,7 +30,7 @@ impl InternalEvent for DecoderMalformedReplacement { ); // NOT the actual number of replacements in the output: there's no easy // way to get that from the lib we use here (encoding_rs) - counter!("decoder_malformed_replacement_warnings_total").increment(1); + counter!(MetricName::DecoderMalformedReplacementWarningsTotal).increment(1); } } @@ -47,6 +47,6 @@ impl InternalEvent for EncoderUnmappableReplacement { ); // NOT the actual number of replacements in the output: there's no easy // way to get that from the lib we use here (encoding_rs) - counter!("encoder_unmappable_replacement_warnings_total").increment(1); + counter!(MetricName::EncoderUnmappableReplacementWarningsTotal).increment(1); } } diff --git a/src/internal_events/eventstoredb_metrics.rs b/src/internal_events/eventstoredb_metrics.rs index c72b9c7dbeb7c..3efc903477980 100644 --- a/src/internal_events/eventstoredb_metrics.rs +++ b/src/internal_events/eventstoredb_metrics.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -16,7 +16,7 @@ impl InternalEvent for EventStoreDbMetricsHttpError { error_type = error_type::REQUEST_FAILED, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::REQUEST_FAILED, ) @@ -38,7 +38,7 @@ impl InternalEvent for EventStoreDbStatsParsingError { error_type = error_type::PARSER_FAILED, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, ) diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index abe226897d5d3..8dfb266dec1dd 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -1,7 +1,7 @@ use std::time::Duration; -use metrics::{counter, histogram}; use tokio::time::error::Elapsed; +use vector_common::{counter, histogram}; use vector_lib::{ NamedInternalEvent, internal_event::{ @@ -28,12 +28,12 @@ impl InternalEvent for ExecEventsReceived<'_> { command = %self.command, ); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "command" => self.command.to_owned(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "command" => self.command.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -57,7 +57,7 @@ impl InternalEvent for ExecFailedError<'_> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "command" => self.command.to_owned(), "error_type" => error_type::COMMAND_FAILED, "error_code" => io_error_code(&self.error), @@ -85,7 +85,7 @@ impl InternalEvent for ExecTimeoutError<'_> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "command" => self.command.to_owned(), "error_type" => error_type::TIMED_OUT, "stage" => error_stage::RECEIVING, @@ -120,14 +120,14 @@ impl InternalEvent for ExecCommandExecuted<'_> { elapsed_millis = %self.exec_duration.as_millis(), ); counter!( - "command_executed_total", + MetricName::CommandExecutedTotal, "command" => self.command.to_owned(), "exit_status" => exit_status.clone(), ) .increment(1); histogram!( - "command_execution_duration_seconds", + MetricName::CommandExecutionDurationSeconds, "exit_status" => exit_status, "command" => self.command.to_owned(), ) @@ -196,7 +196,7 @@ impl InternalEvent for ExecFailedToSignalChildError<'_> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "command" => format!("{:?}", self.command.as_std()), "error_code" => self.error.to_error_code(), "error_type" => error_type::COMMAND_FAILED, @@ -218,7 +218,7 @@ impl InternalEvent for ExecChannelClosedError { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/expansion.rs b/src/internal_events/expansion.rs index 7b2633dd64f97..22d13ab60671b 100644 --- a/src/internal_events/expansion.rs +++ b/src/internal_events/expansion.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -25,7 +25,7 @@ impl InternalEvent for PairExpansionError<'_> { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/file.rs b/src/internal_events/file.rs index 0e85c67150621..3cf36051376da 100644 --- a/src/internal_events/file.rs +++ b/src/internal_events/file.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; -use metrics::{counter, gauge}; +use vector_common::{counter, gauge}; use vector_lib::{ NamedInternalEvent, configurable::configurable_component, @@ -34,7 +34,7 @@ pub struct FileOpen { impl InternalEvent for FileOpen { fn emit(self) { - gauge!("open_files").set(self.count as f64); + gauge!(MetricName::OpenFiles).set(self.count as f64); } } @@ -55,13 +55,13 @@ impl InternalEvent for FileBytesSent<'_> { ); if self.include_file_metric_tag { counter!( - "component_sent_bytes_total", + MetricName::ComponentSentBytesTotal, "protocol" => "file", "file" => self.file.clone().into_owned(), ) } else { counter!( - "component_sent_bytes_total", + MetricName::ComponentSentBytesTotal, "protocol" => "file", ) } @@ -89,7 +89,7 @@ impl InternalEvent for FileIoError<'_, P> { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => self.code, "error_type" => error_type::IO_FAILED, "stage" => error_stage::SENDING, @@ -110,7 +110,7 @@ mod source { use std::{io::Error, path::Path, time::Duration}; use bytes::BytesMut; - use metrics::counter; + use vector_common::counter; use vector_lib::{ NamedInternalEvent, emit, file_source_common::internal_events::FileSourceInternalEvents, @@ -137,13 +137,13 @@ mod source { ); if self.include_file_metric_tag { counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "protocol" => "file", "file" => self.file.to_owned() ) } else { counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "protocol" => "file", ) } @@ -169,18 +169,18 @@ mod source { ); if self.include_file_metric_tag { counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "file" => self.file.to_owned(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "file" => self.file.to_owned(), ) .increment(self.byte_size.get() as u64); } else { - counter!("component_received_events_total").increment(self.count as u64); - counter!("component_received_event_bytes_total") + counter!(MetricName::ComponentReceivedEventsTotal).increment(self.count as u64); + counter!(MetricName::ComponentReceivedEventBytesTotal) .increment(self.byte_size.get() as u64); } } @@ -200,11 +200,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - "checksum_errors_total", + MetricName::ChecksumErrorsTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!("checksum_errors_total") + counter!(MetricName::ChecksumErrorsTotal) } .increment(1); } @@ -229,7 +229,7 @@ mod source { ); if self.include_file_metric_tag { counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "reading_fingerprint", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -237,7 +237,7 @@ mod source { ) } else { counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "reading_fingerprint", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -268,7 +268,7 @@ mod source { ); if self.include_file_metric_tag { counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "file" => self.file.to_string_lossy().into_owned(), "error_code" => DELETION_FAILED, "error_type" => error_type::COMMAND_FAILED, @@ -276,7 +276,7 @@ mod source { ) } else { counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => DELETION_FAILED, "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, @@ -300,11 +300,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - "files_deleted_total", + MetricName::FilesDeletedTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!("files_deleted_total") + counter!(MetricName::FilesDeletedTotal) } .increment(1); } @@ -327,13 +327,13 @@ mod source { ); if self.include_file_metric_tag { counter!( - "files_unwatched_total", + MetricName::FilesUnwatchedTotal, "file" => self.file.to_string_lossy().into_owned(), "reached_eof" => reached_eof, ) } else { counter!( - "files_unwatched_total", + MetricName::FilesUnwatchedTotal, "reached_eof" => reached_eof, ) } @@ -360,7 +360,7 @@ mod source { ); if self.include_file_metric_tag { counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "watching", "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, @@ -368,7 +368,7 @@ mod source { ) } else { counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "watching", "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, @@ -394,11 +394,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - "files_resumed_total", + MetricName::FilesResumedTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!("files_resumed_total") + counter!(MetricName::FilesResumedTotal) } .increment(1); } @@ -418,11 +418,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - "files_added_total", + MetricName::FilesAddedTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!("files_added_total") + counter!(MetricName::FilesAddedTotal) } .increment(1); } @@ -441,7 +441,7 @@ mod source { count = %self.count, duration_ms = self.duration.as_millis() as u64, ); - counter!("checkpoints_total").increment(self.count as u64); + counter!(MetricName::CheckpointsTotal).increment(self.count as u64); } } @@ -460,7 +460,7 @@ mod source { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "writing_checkpoints", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::RECEIVING, @@ -486,7 +486,7 @@ mod source { path = %self.path.display(), ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "globbing", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -513,7 +513,7 @@ mod source { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "reading_line_from_file", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/file_descriptor.rs b/src/internal_events/file_descriptor.rs index 7882ed4d95b12..c328a9b9e5578 100644 --- a/src/internal_events/file_descriptor.rs +++ b/src/internal_events/file_descriptor.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -19,7 +19,7 @@ where stage = error_stage::RECEIVING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/fluent.rs b/src/internal_events/fluent.rs index 6d6bb408edc5f..c1dff26be877e 100644 --- a/src/internal_events/fluent.rs +++ b/src/internal_events/fluent.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -31,7 +31,7 @@ impl InternalEvent for FluentMessageDecodeError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/gcp_pubsub.rs b/src/internal_events/gcp_pubsub.rs index 4066d71936529..52930c099b0f0 100644 --- a/src/internal_events/gcp_pubsub.rs +++ b/src/internal_events/gcp_pubsub.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -18,7 +18,7 @@ impl InternalEvent for GcpPubsubConnectError { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_connecting", "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, @@ -43,7 +43,7 @@ impl InternalEvent for GcpPubsubStreamingPullError { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_streaming_pull", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -68,7 +68,7 @@ impl InternalEvent for GcpPubsubReceiveError { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_fetching_events", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/grpc.rs b/src/internal_events/grpc.rs index 882b1dbfaf33b..ab66a0554de4b 100644 --- a/src/internal_events/grpc.rs +++ b/src/internal_events/grpc.rs @@ -1,8 +1,8 @@ use std::time::Duration; use http::response::Response; -use metrics::{counter, histogram}; use tonic::Code; +use vector_common::{counter, histogram}; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -13,7 +13,7 @@ pub struct GrpcServerRequestReceived; impl InternalEvent for GrpcServerRequestReceived { fn emit(self) { - counter!("grpc_server_messages_received_total").increment(1); + counter!(MetricName::GrpcServerMessagesReceivedTotal).increment(1); } } @@ -34,8 +34,8 @@ impl InternalEvent for GrpcServerResponseSent<'_, B> { let grpc_code = grpc_code_to_name(grpc_code); let labels = &[(GRPC_STATUS_LABEL, grpc_code)]; - counter!("grpc_server_messages_sent_total", labels).increment(1); - histogram!("grpc_server_handler_duration_seconds", labels).record(self.latency); + counter!(MetricName::GrpcServerMessagesSentTotal, labels).increment(1); + histogram!(MetricName::GrpcServerHandlerDurationSeconds, labels).record(self.latency); } } @@ -53,7 +53,7 @@ impl InternalEvent for GrpcInvalidCompressionSchemeError<'_> { stage = error_stage::RECEIVING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) @@ -78,7 +78,7 @@ where stage = error_stage::RECEIVING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/heartbeat.rs b/src/internal_events/heartbeat.rs index 658a24fcb8762..7458a1bb88140 100644 --- a/src/internal_events/heartbeat.rs +++ b/src/internal_events/heartbeat.rs @@ -1,6 +1,6 @@ use std::time::Instant; -use metrics::gauge; +use vector_common::gauge; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::InternalEvent; @@ -14,9 +14,9 @@ pub struct Heartbeat { impl InternalEvent for Heartbeat { fn emit(self) { trace!(target: "vector", message = "Beep."); - gauge!("uptime_seconds").set(self.since.elapsed().as_secs() as f64); + gauge!(MetricName::UptimeSeconds).set(self.since.elapsed().as_secs() as f64); gauge!( - "build_info", + MetricName::BuildInfo, "debug" => built_info::DEBUG, "version" => built_info::PKG_VERSION, "rust_version" => built_info::RUST_VERSION, diff --git a/src/internal_events/host_metrics.rs b/src/internal_events/host_metrics.rs index d60771644571e..382f689f890e9 100644 --- a/src/internal_events/host_metrics.rs +++ b/src/internal_events/host_metrics.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -16,7 +16,7 @@ impl InternalEvent for HostMetricsScrapeError { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, ) @@ -40,7 +40,7 @@ impl InternalEvent for HostMetricsScrapeDetailError { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, ) @@ -66,7 +66,7 @@ impl InternalEvent for HostMetricsScrapeFilesystemError { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/http.rs b/src/internal_events/http.rs index a0d8f5d2a92d3..8a724b9f6b447 100644 --- a/src/internal_events/http.rs +++ b/src/internal_events/http.rs @@ -1,7 +1,7 @@ use std::{error::Error, time::Duration}; use http::Response; -use metrics::{counter, histogram}; +use vector_common::{counter, histogram}; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -16,7 +16,7 @@ pub struct HttpServerRequestReceived; impl InternalEvent for HttpServerRequestReceived { fn emit(self) { debug!(message = "Received HTTP request."); - counter!("http_server_requests_received_total").increment(1); + counter!(MetricName::HttpServerRequestsReceivedTotal).increment(1); } } @@ -32,8 +32,8 @@ impl InternalEvent for HttpServerResponseSent<'_, B> { HTTP_STATUS_LABEL, self.response.status().as_u16().to_string(), )]; - counter!("http_server_responses_sent_total", labels).increment(1); - histogram!("http_server_handler_duration_seconds", labels).record(self.latency); + counter!(MetricName::HttpServerResponsesSentTotal, labels).increment(1); + histogram!(MetricName::HttpServerHandlerDurationSeconds, labels).record(self.latency); } } @@ -53,7 +53,7 @@ impl InternalEvent for HttpBytesReceived<'_> { protocol = %self.protocol ); counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "http_path" => self.http_path.to_string(), "protocol" => self.protocol, ) @@ -79,15 +79,15 @@ impl InternalEvent for HttpEventsReceived<'_> { protocol = %self.protocol, ); - histogram!("component_received_events_count").record(self.count as f64); + histogram!(MetricName::ComponentReceivedEventsCount).record(self.count as f64); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "http_path" => self.http_path.to_string(), "protocol" => self.protocol, ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "http_path" => self.http_path.to_string(), "protocol" => self.protocol, ) @@ -126,7 +126,7 @@ impl InternalEvent for HttpBadRequest<'_> { http_code = %self.code, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::REQUEST_FAILED, "error_stage" => error_stage::RECEIVING, @@ -152,7 +152,7 @@ impl InternalEvent for HttpDecompressError<'_> { encoding = %self.encoding ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_decompressing_payload", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::RECEIVING, @@ -174,7 +174,7 @@ impl InternalEvent for HttpInternalError<'_> { stage = error_stage::RECEIVING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/http_client.rs b/src/internal_events/http_client.rs index d1e4c7549d15a..eeffe87565cbf 100644 --- a/src/internal_events/http_client.rs +++ b/src/internal_events/http_client.rs @@ -5,7 +5,7 @@ use http::{ header::{self, HeaderMap, HeaderValue}, }; use hyper::{Error, body::HttpBody}; -use metrics::{counter, histogram}; +use vector_common::{counter, histogram}; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -39,7 +39,7 @@ impl InternalEvent for AboutToSendHttpRequest<'_, T> { headers = ?remove_sensitive(self.request.headers()), body = %FormatBody(self.request.body()), ); - counter!("http_client_requests_sent_total", "method" => self.request.method().to_string()) + counter!(MetricName::HttpClientRequestsSentTotal, "method" => self.request.method().to_string()) .increment(1); } } @@ -60,13 +60,13 @@ impl InternalEvent for GotHttpResponse<'_, T> { body = %FormatBody(self.response.body()), ); counter!( - "http_client_responses_total", + MetricName::HttpClientResponsesTotal, "status" => self.response.status().as_u16().to_string(), ) .increment(1); - histogram!("http_client_rtt_seconds").record(self.roundtrip); + histogram!(MetricName::HttpClientRttSeconds).record(self.roundtrip); histogram!( - "http_client_response_rtt_seconds", + MetricName::HttpClientResponseRttSeconds, "status" => self.response.status().as_u16().to_string(), ) .record(self.roundtrip); @@ -87,9 +87,10 @@ impl InternalEvent for GotHttpWarning<'_> { error_type = error_type::REQUEST_FAILED, stage = error_stage::PROCESSING, ); - counter!("http_client_errors_total", "error_kind" => self.error.to_string()).increment(1); - histogram!("http_client_rtt_seconds").record(self.roundtrip); - histogram!("http_client_error_rtt_seconds", "error_kind" => self.error.to_string()) + counter!(MetricName::HttpClientErrorsTotal, "error_kind" => self.error.to_string()) + .increment(1); + histogram!(MetricName::HttpClientRttSeconds).record(self.roundtrip); + histogram!(MetricName::HttpClientErrorRttSeconds, "error_kind" => self.error.to_string()) .record(self.roundtrip); } } diff --git a/src/internal_events/http_client_source.rs b/src/internal_events/http_client_source.rs index ff67535c0c14b..1874ea18c8c44 100644 --- a/src/internal_events/http_client_source.rs +++ b/src/internal_events/http_client_source.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] // TODO requires optional feature compilation -use metrics::counter; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -25,12 +25,12 @@ impl InternalEvent for HttpClientEventsReceived { url = %self.url, ); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "uri" => self.url.clone(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "uri" => self.url.clone(), ) .increment(self.byte_size.get() as u64); @@ -53,7 +53,7 @@ impl InternalEvent for HttpClientHttpResponseError { error_code = %http_error_code(self.code.as_u16()), ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "url" => self.url, "stage" => error_stage::RECEIVING, "error_type" => error_type::REQUEST_FAILED, @@ -79,7 +79,7 @@ impl InternalEvent for HttpClientHttpError { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "url" => self.url, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/influxdb.rs b/src/internal_events/influxdb.rs index 22b34c3dc532c..78eb60c0f6281 100644 --- a/src/internal_events/influxdb.rs +++ b/src/internal_events/influxdb.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -20,7 +20,7 @@ impl InternalEvent for InfluxdbEncodingError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/internal_logs.rs b/src/internal_events/internal_logs.rs index 63c520723c9c7..de0d68f3e65e8 100644 --- a/src/internal_events/internal_logs.rs +++ b/src/internal_events/internal_logs.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::{NamedInternalEvent, internal_event::InternalEvent, json_size::JsonSize}; #[derive(Debug, NamedInternalEvent)] @@ -10,7 +10,7 @@ impl InternalEvent for InternalLogsBytesReceived { fn emit(self) { // MUST NOT emit logs here to avoid an infinite log loop counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "protocol" => "internal", ) .increment(self.byte_size as u64); @@ -26,7 +26,8 @@ pub struct InternalLogsEventsReceived { impl InternalEvent for InternalLogsEventsReceived { fn emit(self) { // MUST NOT emit logs here to avoid an infinite log loop - counter!("component_received_events_total").increment(self.count as u64); - counter!("component_received_event_bytes_total").increment(self.byte_size.get() as u64); + counter!(MetricName::ComponentReceivedEventsTotal).increment(self.count as u64); + counter!(MetricName::ComponentReceivedEventBytesTotal) + .increment(self.byte_size.get() as u64); } } diff --git a/src/internal_events/journald.rs b/src/internal_events/journald.rs index 0debba0de5d29..192833b9f533d 100644 --- a/src/internal_events/journald.rs +++ b/src/internal_events/journald.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, codecs::decoding::BoxedFramingError, @@ -21,7 +21,7 @@ impl InternalEvent for JournaldInvalidRecordError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, ) @@ -43,7 +43,7 @@ impl InternalEvent for JournaldStartJournalctlError { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::COMMAND_FAILED, ) @@ -65,7 +65,7 @@ impl InternalEvent for JournaldReadError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::READER_FAILED, ) @@ -89,7 +89,7 @@ impl InternalEvent for JournaldCheckpointSetError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::IO_FAILED, ) @@ -113,7 +113,7 @@ impl InternalEvent for JournaldCheckpointFileOpenError { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::IO_FAILED, ) diff --git a/src/internal_events/kafka.rs b/src/internal_events/kafka.rs index 87ad581e1c453..0847ecbad1cba 100644 --- a/src/internal_events/kafka.rs +++ b/src/internal_events/kafka.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] // TODO requires optional feature compilation -use metrics::{counter, gauge}; +use vector_common::{counter, gauge}; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -26,7 +26,7 @@ impl InternalEvent for KafkaBytesReceived<'_> { partition = %self.partition, ); counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "protocol" => self.protocol, "topic" => self.topic.to_string(), "partition" => self.partition.to_string(), @@ -53,13 +53,13 @@ impl InternalEvent for KafkaEventsReceived<'_> { partition = %self.partition, ); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "topic" => self.topic.to_string(), "partition" => self.partition.to_string(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "topic" => self.topic.to_string(), "partition" => self.partition.to_string(), ) @@ -82,7 +82,7 @@ impl InternalEvent for KafkaOffsetUpdateError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "kafka_offset_update", "error_type" => error_type::READER_FAILED, "stage" => error_stage::SENDING, @@ -106,7 +106,7 @@ impl InternalEvent for KafkaReadError { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "reading_message", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -123,24 +123,24 @@ pub struct KafkaStatisticsReceived<'a> { impl InternalEvent for KafkaStatisticsReceived<'_> { fn emit(self) { - gauge!("kafka_queue_messages").set(self.statistics.msg_cnt as f64); - gauge!("kafka_queue_messages_bytes").set(self.statistics.msg_size as f64); - counter!("kafka_requests_total").absolute(self.statistics.tx as u64); - counter!("kafka_requests_bytes_total").absolute(self.statistics.tx_bytes as u64); - counter!("kafka_responses_total").absolute(self.statistics.rx as u64); - counter!("kafka_responses_bytes_total").absolute(self.statistics.rx_bytes as u64); - counter!("kafka_produced_messages_total").absolute(self.statistics.txmsgs as u64); - counter!("kafka_produced_messages_bytes_total") + gauge!(MetricName::KafkaQueueMessages).set(self.statistics.msg_cnt as f64); + gauge!(MetricName::KafkaQueueMessagesBytes).set(self.statistics.msg_size as f64); + counter!(MetricName::KafkaRequestsTotal).absolute(self.statistics.tx as u64); + counter!(MetricName::KafkaRequestsBytesTotal).absolute(self.statistics.tx_bytes as u64); + counter!(MetricName::KafkaResponsesTotal).absolute(self.statistics.rx as u64); + counter!(MetricName::KafkaResponsesBytesTotal).absolute(self.statistics.rx_bytes as u64); + counter!(MetricName::KafkaProducedMessagesTotal).absolute(self.statistics.txmsgs as u64); + counter!(MetricName::KafkaProducedMessagesBytesTotal) .absolute(self.statistics.txmsg_bytes as u64); - counter!("kafka_consumed_messages_total").absolute(self.statistics.rxmsgs as u64); - counter!("kafka_consumed_messages_bytes_total") + counter!(MetricName::KafkaConsumedMessagesTotal).absolute(self.statistics.rxmsgs as u64); + counter!(MetricName::KafkaConsumedMessagesBytesTotal) .absolute(self.statistics.rxmsg_bytes as u64); if self.expose_lag_metrics { for (topic_id, topic) in &self.statistics.topics { for (partition_id, partition) in &topic.partitions { gauge!( - "kafka_consumer_lag", + MetricName::KafkaConsumerLag, "topic_id" => topic_id.clone(), "partition_id" => partition_id.to_string(), ) @@ -166,7 +166,7 @@ impl InternalEvent for KafkaHeaderExtractionError<'_> { header_field = self.header_field.to_string(), ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "extracting_header", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/kubernetes_logs.rs b/src/internal_events/kubernetes_logs.rs index c6edb03724169..d61119c1928bb 100644 --- a/src/internal_events/kubernetes_logs.rs +++ b/src/internal_events/kubernetes_logs.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{ @@ -37,21 +37,21 @@ impl InternalEvent for KubernetesLogsEventsReceived<'_> { let pod_namespace = pod_info.namespace; counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "pod_name" => pod_name.clone(), "pod_namespace" => pod_namespace.clone(), ) .increment(1); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "pod_name" => pod_name, "pod_namespace" => pod_namespace, ) .increment(self.byte_size.get() as u64); } None => { - counter!("component_received_events_total").increment(1); - counter!("component_received_event_bytes_total") + counter!(MetricName::ComponentReceivedEventsTotal).increment(1); + counter!(MetricName::ComponentReceivedEventBytesTotal) .increment(self.byte_size.get() as u64); } } @@ -75,7 +75,7 @@ impl InternalEvent for KubernetesLogsEventAnnotationError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => ANNOTATION_FAILED, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, @@ -99,7 +99,7 @@ impl InternalEvent for KubernetesLogsEventNamespaceAnnotationError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => ANNOTATION_FAILED, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, @@ -124,7 +124,7 @@ impl InternalEvent for KubernetesLogsEventNodeAnnotationError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => ANNOTATION_FAILED, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, @@ -163,7 +163,7 @@ impl InternalEvent for KubernetesLogsDockerFormatParseError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) @@ -191,7 +191,7 @@ impl InternalEvent for KubernetesLifecycleError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => KUBERNETES_LIFECYCLE, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, @@ -222,7 +222,7 @@ impl InternalEvent for KubernetesMergedLineTooBigError<'_> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "reading_line_from_kubernetes_log", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/log_to_metric.rs b/src/internal_events/log_to_metric.rs index 9fbb64dba0622..77ac2a6cc7375 100644 --- a/src/internal_events/log_to_metric.rs +++ b/src/internal_events/log_to_metric.rs @@ -1,6 +1,6 @@ use std::num::ParseFloatError; -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -22,7 +22,7 @@ impl InternalEvent for LogToMetricFieldNullError<'_> { null_field = %self.field ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "field_null", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -52,7 +52,7 @@ impl InternalEvent for LogToMetricParseFloatError<'_> { stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "failed_parsing_float", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -83,7 +83,7 @@ impl InternalEvent for MetricMetadataInvalidFieldValueError<'_> { stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "invalid_field_value", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -112,7 +112,7 @@ impl InternalEvent for MetricMetadataParseError<'_> { stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => format!("failed_parsing_{}", self.kind), "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -137,7 +137,7 @@ impl InternalEvent for MetricMetadataMetricDetailsNotFoundError { stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "missing_metric_details", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/logplex.rs b/src/internal_events/logplex.rs index b28588c5c2d1e..e5c9816d51796 100644 --- a/src/internal_events/logplex.rs +++ b/src/internal_events/logplex.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -37,7 +37,7 @@ impl InternalEvent for HerokuLogplexRequestReadError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "error_code" => io_error_code(&self.error), "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/loki.rs b/src/internal_events/loki.rs index 523efd7e4f59b..628b5afc38dd6 100644 --- a/src/internal_events/loki.rs +++ b/src/internal_events/loki.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, INTENTIONAL, InternalEvent, error_stage, error_type, @@ -17,7 +17,7 @@ impl InternalEvent for LokiEventUnlabeledError { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "unlabeled_event", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -48,7 +48,7 @@ impl InternalEvent for LokiOutOfOrderEventDroppedError { }); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "out_of_order", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -69,7 +69,7 @@ impl InternalEvent for LokiOutOfOrderEventRewritten { count = self.count, reason = "out_of_order", ); - counter!("rewritten_timestamp_events_total").increment(self.count as u64); + counter!(MetricName::RewrittenTimestampEventsTotal).increment(self.count as u64); } } @@ -90,7 +90,7 @@ impl InternalEvent for LokiTimestampNonParsableEventsDropped { emit!(ComponentEventsDropped:: { count: 1, reason }); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "non-parsable_timestamp", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/lua.rs b/src/internal_events/lua.rs index feb9d04212b88..dc9e0a65e6058 100644 --- a/src/internal_events/lua.rs +++ b/src/internal_events/lua.rs @@ -1,4 +1,4 @@ -use metrics::{counter, gauge}; +use vector_common::{counter, gauge}; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -13,7 +13,7 @@ pub struct LuaGcTriggered { impl InternalEvent for LuaGcTriggered { fn emit(self) { - gauge!("lua_memory_used_bytes").set(self.used_memory as f64); + gauge!(MetricName::LuaMemoryUsedBytes).set(self.used_memory as f64); } } @@ -32,7 +32,7 @@ impl InternalEvent for LuaScriptError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => mlua_error_code(&self.error), "error_type" => error_type::SCRIPT_FAILED, "stage" => error_stage::PROCESSING, @@ -62,7 +62,7 @@ impl InternalEvent for LuaBuildError { internal_log_rate_limit = false, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => lua_build_error_code(&self.error), "error_type" => error_type::SCRIPT_FAILED, "stage" => error_stage:: PROCESSING, diff --git a/src/internal_events/metric_to_log.rs b/src/internal_events/metric_to_log.rs index a536a1b24df24..5c18bbc9970e3 100644 --- a/src/internal_events/metric_to_log.rs +++ b/src/internal_events/metric_to_log.rs @@ -1,5 +1,5 @@ -use metrics::counter; use serde_json::Error; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -20,7 +20,7 @@ impl InternalEvent for MetricToLogSerializeError { stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/mongodb_metrics.rs b/src/internal_events/mongodb_metrics.rs index 3cad1e4ef97f9..0df492c5ea5bf 100644 --- a/src/internal_events/mongodb_metrics.rs +++ b/src/internal_events/mongodb_metrics.rs @@ -1,5 +1,5 @@ -use metrics::counter; use mongodb::{bson, error::Error as MongoError}; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -23,12 +23,12 @@ impl InternalEvent for MongoDbMetricsEventsReceived<'_> { endpoint = self.endpoint, ); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -51,7 +51,7 @@ impl InternalEvent for MongoDbMetricsRequestError<'_> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) @@ -75,7 +75,7 @@ impl InternalEvent for MongoDbMetricsBsonParseError<'_> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::RECEIVING, "endpoint" => self.endpoint.to_owned(), diff --git a/src/internal_events/mqtt.rs b/src/internal_events/mqtt.rs index 1e406a9494f1f..c57c5fd130d13 100644 --- a/src/internal_events/mqtt.rs +++ b/src/internal_events/mqtt.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; -use metrics::counter; use rumqttc::ConnectionError; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -20,7 +20,7 @@ impl InternalEvent for MqttConnectionError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "mqtt_connection_error", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, diff --git a/src/internal_events/nginx_metrics.rs b/src/internal_events/nginx_metrics.rs index a3384d4ef0faf..d4fcd8d7cf7d7 100644 --- a/src/internal_events/nginx_metrics.rs +++ b/src/internal_events/nginx_metrics.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -23,12 +23,12 @@ impl InternalEvent for NginxMetricsEventsReceived<'_> { endpoint = self.endpoint, ); counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.count as u64); counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -51,7 +51,7 @@ impl InternalEvent for NginxMetricsRequestError<'_> { stage = error_stage::RECEIVING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "endpoint" => self.endpoint.to_owned(), "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -76,7 +76,7 @@ impl InternalEvent for NginxMetricsStubStatusParseError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "endpoint" => self.endpoint.to_owned(), "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/open.rs b/src/internal_events/open.rs index e48e0ac337820..5fbe15817486c 100644 --- a/src/internal_events/open.rs +++ b/src/internal_events/open.rs @@ -6,7 +6,7 @@ use std::{ }, }; -use metrics::gauge; +use vector_common::gauge; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::InternalEvent; @@ -17,7 +17,7 @@ pub struct ConnectionOpen { impl InternalEvent for ConnectionOpen { fn emit(self) { - gauge!("open_connections").set(self.count as f64); + gauge!(MetricName::OpenConnections).set(self.count as f64); } } @@ -28,7 +28,7 @@ pub struct EndpointsActive { impl InternalEvent for EndpointsActive { fn emit(self) { - gauge!("active_endpoints").set(self.count as f64); + gauge!(MetricName::ActiveEndpoints).set(self.count as f64); } } diff --git a/src/internal_events/parser.rs b/src/internal_events/parser.rs index 85a3e1383afa3..fdd890dfd1b41 100644 --- a/src/internal_events/parser.rs +++ b/src/internal_events/parser.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -36,7 +36,7 @@ impl InternalEvent for ParserMatchError<'_> { field = &truncate_string_at(&String::from_utf8_lossy(self.value), 60)[..] ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "no_match_found", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -66,7 +66,7 @@ impl InternalEvent for ParserMissingFieldError<'_, DROP_ stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "field_not_found", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -97,7 +97,7 @@ impl InternalEvent for ParserConversionError<'_> { stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "type_conversion", "error_type" => error_type::CONVERSION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/postgresql_metrics.rs b/src/internal_events/postgresql_metrics.rs index d6a58f968ab7f..710df6203525d 100644 --- a/src/internal_events/postgresql_metrics.rs +++ b/src/internal_events/postgresql_metrics.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -18,7 +18,7 @@ impl InternalEvent for PostgresqlMetricsCollectError<'_> { endpoint = %self.endpoint, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/process.rs b/src/internal_events/process.rs index 987724c2da18d..7c3da4d089a68 100644 --- a/src/internal_events/process.rs +++ b/src/internal_events/process.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -17,7 +17,7 @@ impl InternalEvent for VectorStarted { arch = built_info::TARGET_ARCH, revision = built_info::VECTOR_BUILD_DESC.unwrap_or(""), ); - counter!("started_total").increment(1); + counter!(MetricName::StartedTotal).increment(1); } } @@ -34,7 +34,7 @@ impl InternalEvent for VectorReloaded<'_> { path = ?self.config_paths, internal_log_rate_limit = false, ); - counter!("reloaded_total").increment(1); + counter!(MetricName::ReloadedTotal).increment(1); } } @@ -59,7 +59,7 @@ impl InternalEvent for VectorStopped { target: "vector", message = "Vector has stopped.", ); - counter!("stopped_total").increment(1); + counter!(MetricName::StoppedTotal).increment(1); } } @@ -72,7 +72,7 @@ impl InternalEvent for VectorQuit { target: "vector", message = "Vector has quit.", ); - counter!("quit_total").increment(1); + counter!(MetricName::QuitTotal).increment(1); } } @@ -92,7 +92,7 @@ impl InternalEvent for VectorReloadError { internal_log_rate_limit = false, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "reload", "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::PROCESSING, @@ -115,7 +115,7 @@ impl InternalEvent for VectorConfigLoadError { internal_log_rate_limit = false, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "config_load", "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::PROCESSING, @@ -137,7 +137,7 @@ impl InternalEvent for VectorRecoveryError { internal_log_rate_limit = false, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "recovery", "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/prometheus.rs b/src/internal_events/prometheus.rs index 27b28fb5ffafa..a4b7b1d3878ba 100644 --- a/src/internal_events/prometheus.rs +++ b/src/internal_events/prometheus.rs @@ -3,7 +3,7 @@ #[cfg(feature = "sources-prometheus-scrape")] use std::borrow::Cow; -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -34,7 +34,7 @@ impl InternalEvent for PrometheusParseError<'_> { url = %self.url ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, "url" => self.url.to_string(), @@ -57,7 +57,7 @@ impl InternalEvent for PrometheusRemoteWriteParseError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) @@ -77,7 +77,7 @@ impl InternalEvent for PrometheusNormalizationError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONVERSION_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/pulsar.rs b/src/internal_events/pulsar.rs index a2212ef0d5971..dd2f9f3df1ddd 100644 --- a/src/internal_events/pulsar.rs +++ b/src/internal_events/pulsar.rs @@ -2,7 +2,7 @@ #[cfg(feature = "sources-pulsar")] use metrics::Counter; -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -24,7 +24,7 @@ impl InternalEvent for PulsarSendingError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::SENDING, ) @@ -51,7 +51,7 @@ impl InternalEvent for PulsarPropertyExtractionError { property_field = %self.property_field, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "extracting_property", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -77,21 +77,21 @@ pub struct PulsarErrorEventData { registered_event!( PulsarErrorEvent => { ack_errors: Counter = counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "acknowledge_message", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::RECEIVING, ), nack_errors: Counter = counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "negative_acknowledge_message", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::RECEIVING, ), read_errors: Counter = counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "reading_message", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/redis.rs b/src/internal_events/redis.rs index 45d76f3670dcd..c9f94cd3a65bf 100644 --- a/src/internal_events/redis.rs +++ b/src/internal_events/redis.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -25,7 +25,7 @@ impl InternalEvent for RedisReceiveEventError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/reduce.rs b/src/internal_events/reduce.rs index 8917c5aad0a5a..fa9bcd56e1fb8 100644 --- a/src/internal_events/reduce.rs +++ b/src/internal_events/reduce.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use vrl::{path::PathParseError, value::KeyString}; @@ -8,7 +8,7 @@ pub struct ReduceStaleEventFlushed; impl InternalEvent for ReduceStaleEventFlushed { fn emit(self) { - counter!("stale_events_flushed_total").increment(1); + counter!(MetricName::StaleEventsFlushedTotal).increment(1); } } @@ -28,7 +28,7 @@ impl InternalEvent for ReduceAddEventError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/remap.rs b/src/internal_events/remap.rs index 989a6aa064065..156721279717e 100644 --- a/src/internal_events/remap.rs +++ b/src/internal_events/remap.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -21,7 +21,7 @@ impl InternalEvent for RemapMappingError { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONVERSION_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/sematext_metrics.rs b/src/internal_events/sematext_metrics.rs index 65d23c53e00ef..ded18044fd26c 100644 --- a/src/internal_events/sematext_metrics.rs +++ b/src/internal_events/sematext_metrics.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -23,7 +23,7 @@ impl InternalEvent for SematextMetricsInvalidMetricError<'_> { kind = ?self.metric.kind(), ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "invalid_metric", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, @@ -49,7 +49,7 @@ impl InternalEvent for SematextMetricsEncodeEventError stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/socket.rs b/src/internal_events/socket.rs index f0b58ce33bbd7..39d7ded04b96d 100644 --- a/src/internal_events/socket.rs +++ b/src/internal_events/socket.rs @@ -1,6 +1,6 @@ use std::net::Ipv4Addr; -use metrics::{counter, histogram}; +use vector_common::{counter, histogram}; use vector_lib::{ NamedInternalEvent, internal_event::{ @@ -42,11 +42,11 @@ impl InternalEvent for SocketBytesReceived { %protocol, ); counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "protocol" => protocol, ) .increment(self.byte_size as u64); - histogram!("component_received_bytes").record(self.byte_size as f64); + histogram!(MetricName::ComponentReceivedBytes).record(self.byte_size as f64); } } @@ -66,10 +66,12 @@ impl InternalEvent for SocketEventsReceived { byte_size = self.byte_size.get(), %mode, ); - counter!("component_received_events_total", "mode" => mode).increment(self.count as u64); - counter!("component_received_event_bytes_total", "mode" => mode) + counter!(MetricName::ComponentReceivedEventsTotal, "mode" => mode) + .increment(self.count as u64); + counter!(MetricName::ComponentReceivedEventBytesTotal, "mode" => mode) .increment(self.byte_size.get() as u64); - histogram!("component_received_bytes", "mode" => mode).record(self.byte_size.get() as f64); + histogram!(MetricName::ComponentReceivedBytes, "mode" => mode) + .record(self.byte_size.get() as f64); } } @@ -88,7 +90,7 @@ impl InternalEvent for SocketBytesSent { %protocol, ); counter!( - "component_sent_bytes_total", + MetricName::ComponentSentBytesTotal, "protocol" => protocol, ) .increment(self.byte_size as u64); @@ -105,8 +107,9 @@ pub struct SocketEventsSent { impl InternalEvent for SocketEventsSent { fn emit(self) { trace!(message = "Events sent.", count = %self.count, byte_size = %self.byte_size.get()); - counter!("component_sent_events_total", "mode" => self.mode.as_str()).increment(self.count); - counter!("component_sent_event_bytes_total", "mode" => self.mode.as_str()) + counter!(MetricName::ComponentSentEventsTotal, "mode" => self.mode.as_str()) + .increment(self.count); + counter!(MetricName::ComponentSentEventBytesTotal, "mode" => self.mode.as_str()) .increment(self.byte_size.get() as u64); } } @@ -129,7 +132,7 @@ impl InternalEvent for SocketBindError { %mode, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "socket_bind", "error_type" => error_type::IO_FAILED, "stage" => error_stage::INITIALIZING, @@ -164,7 +167,7 @@ impl InternalEvent for SocketMulticastGroupJoinError { %interface, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "socket_multicast_group_join", "error_type" => error_type::IO_FAILED, "stage" => error_stage::INITIALIZING, @@ -194,7 +197,7 @@ impl InternalEvent for SocketReceiveError { %mode, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "socket_receive", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -223,7 +226,7 @@ impl InternalEvent for SocketSendError { %mode, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "socket_send", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index 6dcd63084d8e6..e26f1a165e647 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -35,7 +35,7 @@ mod sink { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "serializing_json", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, @@ -63,13 +63,13 @@ mod sink { kind = ?self.kind, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::INVALID_METRIC, "stage" => error_stage::PROCESSING, ) .increment(1); counter!( - "component_discarded_events_total", + MetricName::ComponentDiscardedEventsTotal, "error_type" => error_type::INVALID_METRIC, "stage" => error_stage::PROCESSING, ) @@ -92,7 +92,7 @@ mod sink { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "invalid_response", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::SENDING, @@ -117,7 +117,7 @@ mod sink { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "indexer_ack_failed", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::SENDING, @@ -141,7 +141,7 @@ mod sink { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "indexer_ack_unavailable", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::SENDING, @@ -155,7 +155,7 @@ mod sink { impl InternalEvent for SplunkIndexerAcknowledgementAckAdded { fn emit(self) { - gauge!("splunk_pending_acks").increment(1.0); + gauge!(MetricName::SplunkPendingAcks).increment(1.0); } } @@ -166,7 +166,7 @@ mod sink { impl InternalEvent for SplunkIndexerAcknowledgementAcksRemoved { fn emit(self) { - gauge!("splunk_pending_acks").decrement(self.count); + gauge!(MetricName::SplunkPendingAcks).decrement(self.count); } } @@ -197,7 +197,7 @@ mod sink { #[cfg(feature = "sources-splunk_hec")] mod source { - use metrics::counter; + use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -218,7 +218,7 @@ mod source { stage = error_stage::PROCESSING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "invalid_request_body", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -243,7 +243,7 @@ mod source { stage = error_stage::RECEIVING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::AUTHENTICATION_FAILED, "stage" => error_stage::RECEIVING, ) @@ -257,7 +257,7 @@ mod source { stage = error_stage::RECEIVING ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/statsd_sink.rs b/src/internal_events/statsd_sink.rs index 7f0ee81f48ddc..6de9366d8fc79 100644 --- a/src/internal_events/statsd_sink.rs +++ b/src/internal_events/statsd_sink.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -24,7 +24,7 @@ impl InternalEvent for StatsdInvalidMetricError<'_> { kind = ?self.kind, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "invalid_metric", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/tag_cardinality_limit.rs b/src/internal_events/tag_cardinality_limit.rs index 83a82acd342ae..3441e5ab679d6 100644 --- a/src/internal_events/tag_cardinality_limit.rs +++ b/src/internal_events/tag_cardinality_limit.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; @@ -20,13 +20,13 @@ impl InternalEvent for TagCardinalityLimitRejectingEvent<'_> { ); if self.include_extended_tags { counter!( - "tag_value_limit_exceeded_total", + MetricName::TagValueLimitExceededTotal, "metric_name" => self.metric_name.to_string(), "tag_key" => self.tag_key.to_string(), ) .increment(1); } else { - counter!("tag_value_limit_exceeded_total").increment(1); + counter!(MetricName::TagValueLimitExceededTotal).increment(1); } emit!(ComponentEventsDropped:: { @@ -54,13 +54,13 @@ impl InternalEvent for TagCardinalityLimitRejectingTag<'_> { ); if self.include_extended_tags { counter!( - "tag_value_limit_exceeded_total", + MetricName::TagValueLimitExceededTotal, "metric_name" => self.metric_name.to_string(), "tag_key" => self.tag_key.to_string(), ) .increment(1); } else { - counter!("tag_value_limit_exceeded_total").increment(1); + counter!(MetricName::TagValueLimitExceededTotal).increment(1); } } } @@ -76,6 +76,6 @@ impl InternalEvent for TagCardinalityValueLimitReached<'_> { message = "Value_limit reached for key. New values for this key will be rejected.", key = %self.key, ); - counter!("value_limit_reached_total").increment(1); + counter!(MetricName::ValueLimitReachedTotal).increment(1); } } diff --git a/src/internal_events/tcp.rs b/src/internal_events/tcp.rs index a121eef1e0327..b813e55ab155d 100644 --- a/src/internal_events/tcp.rs +++ b/src/internal_events/tcp.rs @@ -1,6 +1,6 @@ use std::net::SocketAddr; -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -18,7 +18,7 @@ impl InternalEvent for TcpSocketConnectionEstablished { } else { debug!(message = "Connected.", peer_addr = "unknown"); } - counter!("connection_established_total", "mode" => "tcp").increment(1); + counter!(MetricName::ConnectionEstablishedTotal, "mode" => "tcp").increment(1); } } @@ -41,7 +41,7 @@ pub struct TcpSocketConnectionShutdown; impl InternalEvent for TcpSocketConnectionShutdown { fn emit(self) { warn!(message = "Received EOF from the server, shutdown."); - counter!("connection_shutdown_total", "mode" => "tcp").increment(1); + counter!(MetricName::ConnectionShutdownTotal, "mode" => "tcp").increment(1); } } @@ -63,7 +63,7 @@ impl InternalEvent for TcpSocketError<'_, E> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::PROCESSING, ) @@ -100,7 +100,7 @@ impl InternalEvent for TcpSocketTlsConnectionError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "connection_failed", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -127,7 +127,7 @@ impl InternalEvent for TcpSendAckError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "ack_failed", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -152,7 +152,7 @@ impl InternalEvent for TcpBytesReceived { peer_addr = %self.peer_addr, ); counter!( - "component_received_bytes_total", "protocol" => "tcp" + MetricName::ComponentReceivedBytesTotal, "protocol" => "tcp" ) .increment(self.byte_size as u64); } diff --git a/src/internal_events/template.rs b/src/internal_events/template.rs index 147418042a0c6..a482ebd638f59 100644 --- a/src/internal_events/template.rs +++ b/src/internal_events/template.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -29,7 +29,7 @@ impl InternalEvent for TemplateRenderingError<'_> { ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::TEMPLATE_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/throttle.rs b/src/internal_events/throttle.rs index 274fedd7741b9..81ca220976eef 100644 --- a/src/internal_events/throttle.rs +++ b/src/internal_events/throttle.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; @@ -23,7 +23,7 @@ impl InternalEvent for ThrottleEventDiscarded { // if we should change the specification wording? Sort of a similar situation to the // `error_code` tag for the component errors metric, where it's meant to be optional and // only specified when relevant. - counter!("events_discarded_total", "key" => self.key).increment(1); // Deprecated. + counter!(MetricName::EventsDiscardedTotal, "key" => self.key).increment(1); // Deprecated. } emit!(ComponentEventsDropped:: { diff --git a/src/internal_events/udp.rs b/src/internal_events/udp.rs index 0602d4fdb3329..9b83143c9bdd3 100644 --- a/src/internal_events/udp.rs +++ b/src/internal_events/udp.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -14,7 +14,7 @@ pub struct UdpSocketConnectionEstablished; impl InternalEvent for UdpSocketConnectionEstablished { fn emit(self) { debug!(message = "Connected."); - counter!("connection_established_total", "mode" => "udp").increment(1); + counter!(MetricName::ConnectionEstablishedTotal, "mode" => "udp").increment(1); } } @@ -51,13 +51,13 @@ impl InternalEvent for UdpSendIncompleteError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) .increment(1); // deprecated - counter!("connection_send_errors_total", "mode" => "udp").increment(1); + counter!(MetricName::ConnectionSendErrorsTotal, "mode" => "udp").increment(1); emit!(ComponentEventsDropped:: { count: 1, reason }); } @@ -80,7 +80,7 @@ impl InternalEvent for UdpChunkingError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) diff --git a/src/internal_events/unix.rs b/src/internal_events/unix.rs index 6fab3348dc4d7..ff429a8cec5d7 100644 --- a/src/internal_events/unix.rs +++ b/src/internal_events/unix.rs @@ -2,7 +2,7 @@ use std::{io::Error, path::Path}; -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -18,7 +18,7 @@ pub struct UnixSocketConnectionEstablished<'a> { impl InternalEvent for UnixSocketConnectionEstablished<'_> { fn emit(self) { debug!(message = "Connected.", path = ?self.path); - counter!("connection_established_total", "mode" => "unix").increment(1); + counter!(MetricName::ConnectionEstablishedTotal, "mode" => "unix").increment(1); } } @@ -59,7 +59,7 @@ impl InternalEvent for UnixSocketError<'_, E> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::PROCESSING, ) @@ -84,7 +84,7 @@ impl InternalEvent for UnixSocketSendError<'_, E> { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) @@ -112,7 +112,7 @@ impl InternalEvent for UnixSendIncompleteError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) @@ -139,7 +139,7 @@ impl InternalEvent for UnixSocketFileDeleteError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "delete_socket_file", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/websocket.rs b/src/internal_events/websocket.rs index 960aec1916133..71f3c8a8e7ba9 100644 --- a/src/internal_events/websocket.rs +++ b/src/internal_events/websocket.rs @@ -5,8 +5,8 @@ use std::{ fmt::{Debug, Display, Formatter, Result}, }; -use metrics::{counter, histogram}; use tokio_tungstenite::tungstenite::error::Error as TungsteniteError; +use vector_common::{counter, histogram}; use vector_common::{ internal_event::{error_stage, error_type}, json_size::JsonSize, @@ -22,7 +22,7 @@ pub struct WebSocketConnectionEstablished; impl InternalEvent for WebSocketConnectionEstablished { fn emit(self) { debug!(message = "Connected."); - counter!("connection_established_total").increment(1); + counter!(MetricName::ConnectionEstablishedTotal).increment(1); } } @@ -41,7 +41,7 @@ impl InternalEvent for WebSocketConnectionFailedError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_connection_failed", "error_type" => error_type::CONNECTION_FAILED, @@ -57,7 +57,7 @@ pub struct WebSocketConnectionShutdown; impl InternalEvent for WebSocketConnectionShutdown { fn emit(self) { warn!(message = "Closed by the server."); - counter!("connection_shutdown_total").increment(1); + counter!(MetricName::ConnectionShutdownTotal).increment(1); } } @@ -76,7 +76,7 @@ impl InternalEvent for WebSocketConnectionError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_connection_error", "error_type" => error_type::WRITER_FAILED, @@ -121,7 +121,7 @@ impl InternalEvent for WebSocketBytesReceived<'_> { kind = %self.kind ); let counter = counter!( - "component_received_bytes_total", + MetricName::ComponentReceivedBytesTotal, "url" => self.url.to_string(), "protocol" => self.protocol, "kind" => self.kind.to_string() @@ -150,17 +150,17 @@ impl InternalEvent for WebSocketMessageReceived<'_> { kind = %self.kind ); - let histogram = histogram!("component_received_events_count"); + let histogram = histogram!(MetricName::ComponentReceivedEventsCount); histogram.record(self.count as f64); let counter = counter!( - "component_received_events_total", + MetricName::ComponentReceivedEventsTotal, "uri" => self.url.to_string(), "protocol" => PROTOCOL, "kind" => self.kind.to_string() ); counter.increment(self.count as u64); let counter = counter!( - "component_received_event_bytes_total", + MetricName::ComponentReceivedEventBytesTotal, "url" => self.url.to_string(), "protocol" => PROTOCOL, "kind" => self.kind.to_string() @@ -184,7 +184,7 @@ impl InternalEvent for WebSocketReceiveError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_receive_error", "error_type" => error_type::CONNECTION_FAILED, @@ -209,7 +209,7 @@ impl InternalEvent for WebSocketSendError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_send_error", "error_type" => error_type::CONNECTION_FAILED, diff --git a/src/internal_events/websocket_server.rs b/src/internal_events/websocket_server.rs index fd064c41f2f8a..b6dcebd45a0b5 100644 --- a/src/internal_events/websocket_server.rs +++ b/src/internal_events/websocket_server.rs @@ -1,6 +1,6 @@ use std::{error::Error, fmt::Debug}; -use metrics::{counter, gauge}; +use vector_common::{counter, gauge}; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -18,8 +18,8 @@ impl InternalEvent for WebSocketListenerConnectionEstablished { self.client_count ) ); - counter!("connection_established_total", &self.extra_tags).increment(1); - gauge!("active_clients", &self.extra_tags).set(self.client_count as f64); + counter!(MetricName::ConnectionEstablishedTotal, &self.extra_tags).increment(1); + gauge!(MetricName::ActiveClients, &self.extra_tags).set(self.client_count as f64); } } @@ -49,7 +49,7 @@ impl InternalEvent for WebSocketListenerConnectionFailedError { ]); // Tags required by `component_errors_total` are dynamically added above. // ## skip check-validity-events ## - counter!("component_errors_total", &all_tags).increment(1); + counter!(MetricName::ComponentErrorsTotal, &all_tags).increment(1); } } @@ -67,8 +67,8 @@ impl InternalEvent for WebSocketListenerConnectionShutdown { self.client_count ) ); - counter!("connection_shutdown_total", &self.extra_tags).increment(1); - gauge!("active_clients", &self.extra_tags).set(self.client_count as f64); + counter!(MetricName::ConnectionShutdownTotal, &self.extra_tags).increment(1); + gauge!(MetricName::ActiveClients, &self.extra_tags).set(self.client_count as f64); } } @@ -87,7 +87,7 @@ impl InternalEvent for WebSocketListenerSendError { stage = error_stage::SENDING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "ws_server_connection_error", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -104,8 +104,8 @@ pub struct WebSocketListenerMessageSent { impl InternalEvent for WebSocketListenerMessageSent { fn emit(self) { - counter!("websocket_messages_sent_total", &self.extra_tags).increment(1); - counter!("websocket_bytes_sent_total", &self.extra_tags) + counter!(MetricName::WebsocketMessagesSentTotal, &self.extra_tags).increment(1); + counter!(MetricName::WebsocketBytesSentTotal, &self.extra_tags) .increment(self.message_size as u64); } } diff --git a/src/internal_events/windows.rs b/src/internal_events/windows.rs index 7b36e2fa62466..41c8491b6d961 100644 --- a/src/internal_events/windows.rs +++ b/src/internal_events/windows.rs @@ -1,4 +1,4 @@ -use metrics::counter; +use vector_common::counter; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; @@ -16,7 +16,7 @@ impl InternalEvent for WindowsServiceStart<'_> { "Started Windows Service.", ); counter!( - "windows_service_start_total", + MetricName::WindowsServiceStartTotal, "already_started" => self.already_started.to_string(), ) .increment(1); @@ -37,7 +37,7 @@ impl InternalEvent for WindowsServiceStop<'_> { "Stopped Windows Service.", ); counter!( - "windows_service_stop_total", + MetricName::WindowsServiceStopTotal, "already_stopped" => self.already_stopped.to_string(), ) .increment(1); @@ -55,7 +55,7 @@ impl InternalEvent for WindowsServiceRestart<'_> { name = ?self.name, "Restarted Windows Service." ); - counter!("windows_service_restart_total").increment(1) + counter!(MetricName::WindowsServiceRestartTotal).increment(1) } } @@ -70,7 +70,7 @@ impl InternalEvent for WindowsServiceInstall<'_> { name = ?self.name, "Installed Windows Service.", ); - counter!("windows_service_install_total").increment(1); + counter!(MetricName::WindowsServiceInstallTotal).increment(1); } } @@ -85,7 +85,7 @@ impl InternalEvent for WindowsServiceUninstall<'_> { name = ?self.name, "Uninstalled Windows Service.", ); - counter!("windows_service_uninstall_total").increment(1); + counter!(MetricName::WindowsServiceUninstallTotal).increment(1); } } @@ -104,7 +104,7 @@ impl InternalEvent for WindowsServiceDoesNotExistError<'_> { stage = error_stage::PROCESSING, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "service_missing", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/windows_event_log.rs b/src/internal_events/windows_event_log.rs index ae5363e2c52be..77d43979bb6ae 100644 --- a/src/internal_events/windows_event_log.rs +++ b/src/internal_events/windows_event_log.rs @@ -1,5 +1,5 @@ -use metrics::counter; use tracing::error; +use vector_common::counter; use vector_lib::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, @@ -25,7 +25,7 @@ impl InternalEvent for WindowsEventLogParseError { internal_log_rate_limit = true, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "parse_failed", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -54,7 +54,7 @@ impl InternalEvent for WindowsEventLogQueryError { internal_log_rate_limit = true, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "query_failed", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -81,7 +81,7 @@ impl InternalEvent for WindowsEventLogBookmarkError { internal_log_rate_limit = true, ); counter!( - "component_errors_total", + MetricName::ComponentErrorsTotal, "error_code" => "bookmark_failed", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::PROCESSING, From aa0e25377ae2424d4261fe807a687b339fc1b0c3 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 18:06:34 -0400 Subject: [PATCH 04/17] Format --- lib/vector-common/src/internal_event/mod.rs | 2 +- lib/vector-core/src/latency.rs | 2 +- lib/vector-core/src/source_sender/builder.rs | 2 +- lib/vector-core/src/source_sender/sender.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/vector-common/src/internal_event/mod.rs b/lib/vector-common/src/internal_event/mod.rs index 7ee08bd541d37..0d1ace81fbbd1 100644 --- a/lib/vector-common/src/internal_event/mod.rs +++ b/lib/vector-common/src/internal_event/mod.rs @@ -17,10 +17,10 @@ pub use bytes_sent::BytesSent; #[allow(clippy::module_name_repetitions)] pub use cached_event::{RegisterTaggedInternalEvent, RegisteredEventCache}; pub use component_events_dropped::{ComponentEventsDropped, INTENTIONAL, UNINTENTIONAL}; -pub use metric_name::MetricName; pub use component_events_timed_out::ComponentEventsTimedOut; pub use events_received::{EventsReceived, EventsReceivedHandle}; pub use events_sent::{DEFAULT_OUTPUT, EventsSent, TaggedEventsSent}; +pub use metric_name::MetricName; pub use metrics::SharedString; pub use optional_tag::OptionalTag; pub use prelude::{error_stage, error_type}; diff --git a/lib/vector-core/src/latency.rs b/lib/vector-core/src/latency.rs index 70c04073e824e..3dd9da20da65d 100644 --- a/lib/vector-core/src/latency.rs +++ b/lib/vector-core/src/latency.rs @@ -1,8 +1,8 @@ use std::time::Instant; use metrics::Histogram; -use vector_common::{gauge, histogram, internal_event::MetricName}; use vector_common::stats::EwmaGauge; +use vector_common::{gauge, histogram, internal_event::MetricName}; use crate::event::EventArray; diff --git a/lib/vector-core/src/source_sender/builder.rs b/lib/vector-core/src/source_sender/builder.rs index ddaf9617d54a0..7f9f5d522497a 100644 --- a/lib/vector-core/src/source_sender/builder.rs +++ b/lib/vector-core/src/source_sender/builder.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, time::Duration}; -use vector_common::histogram; use vector_buffers::topology::channel::LimitedReceiver; +use vector_common::histogram; use vector_common::internal_event::DEFAULT_OUTPUT; use super::{ diff --git a/lib/vector-core/src/source_sender/sender.rs b/lib/vector-core/src/source_sender/sender.rs index 50b6d5cf67f90..d5834ab0edff5 100644 --- a/lib/vector-core/src/source_sender/sender.rs +++ b/lib/vector-core/src/source_sender/sender.rs @@ -5,12 +5,12 @@ use std::{collections::HashMap, time::Instant}; use futures::Stream; #[cfg(any(test, feature = "test"))] use futures::StreamExt as _; -#[cfg(any(test, feature = "test"))] -use vector_common::histogram; use vector_buffers::EventCount; #[cfg(any(test, feature = "test"))] use vector_buffers::topology::channel::LimitedReceiver; #[cfg(any(test, feature = "test"))] +use vector_common::histogram; +#[cfg(any(test, feature = "test"))] use vector_common::internal_event::DEFAULT_OUTPUT; #[cfg(doc)] use vector_common::internal_event::{ComponentEventsDropped, EventsSent}; From bf4397f48a913da7d418b573c0a742f39de01d9c Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 18:45:43 -0400 Subject: [PATCH 05/17] Fix EventName imports --- lib/vector-lib/src/lib.rs | 6 +++--- src/internal_events/adaptive_concurrency.rs | 3 ++- src/internal_events/aggregate.rs | 5 ++--- src/internal_events/amqp.rs | 5 ++--- src/internal_events/apache_metrics.rs | 4 ++-- src/internal_events/api.rs | 5 ++--- src/internal_events/aws.rs | 5 ++--- src/internal_events/aws_cloudwatch_logs.rs | 5 ++--- src/internal_events/aws_ec2_metadata.rs | 5 ++--- src/internal_events/aws_ecs_metrics.rs | 4 ++-- src/internal_events/aws_kinesis.rs | 6 +++--- src/internal_events/aws_kinesis_firehose.rs | 5 ++--- src/internal_events/aws_sqs.rs | 6 +++--- src/internal_events/batch.rs | 5 ++--- src/internal_events/common.rs | 4 ++-- src/internal_events/conditions.rs | 5 ++--- src/internal_events/datadog_agent.rs | 5 ++--- src/internal_events/datadog_metrics.rs | 5 ++--- src/internal_events/datadog_traces.rs | 5 ++--- src/internal_events/dnstap.rs | 5 ++--- src/internal_events/docker_logs.rs | 4 ++-- src/internal_events/doris.rs | 3 +-- src/internal_events/encoding_transcode.rs | 5 ++--- src/internal_events/eventstoredb_metrics.rs | 5 ++--- src/internal_events/exec.rs | 4 ++-- src/internal_events/expansion.rs | 5 ++--- src/internal_events/file.rs | 8 ++++---- src/internal_events/file_descriptor.rs | 5 ++--- src/internal_events/fluent.rs | 5 ++--- src/internal_events/gcp_pubsub.rs | 5 ++--- src/internal_events/grpc.rs | 4 ++-- src/internal_events/heartbeat.rs | 5 ++--- src/internal_events/host_metrics.rs | 5 ++--- src/internal_events/http.rs | 4 ++-- src/internal_events/http_client.rs | 4 ++-- src/internal_events/http_client_source.rs | 4 ++-- src/internal_events/influxdb.rs | 5 ++--- src/internal_events/internal_logs.rs | 3 +-- src/internal_events/journald.rs | 4 ++-- src/internal_events/kafka.rs | 4 ++-- src/internal_events/kubernetes_logs.rs | 4 ++-- src/internal_events/log_to_metric.rs | 5 ++--- src/internal_events/logplex.rs | 5 ++--- src/internal_events/loki.rs | 5 ++--- src/internal_events/lua.rs | 4 ++-- src/internal_events/metric_to_log.rs | 5 ++--- src/internal_events/mongodb_metrics.rs | 4 ++-- src/internal_events/mqtt.rs | 5 ++--- src/internal_events/nginx_metrics.rs | 4 ++-- src/internal_events/open.rs | 5 ++--- src/internal_events/parser.rs | 5 ++--- src/internal_events/postgresql_metrics.rs | 5 ++--- src/internal_events/process.rs | 5 ++--- src/internal_events/prometheus.rs | 5 ++--- src/internal_events/pulsar.rs | 5 ++--- src/internal_events/redis.rs | 5 ++--- src/internal_events/reduce.rs | 5 ++--- src/internal_events/remap.rs | 5 ++--- src/internal_events/sematext_metrics.rs | 5 ++--- src/internal_events/socket.rs | 4 ++-- src/internal_events/splunk_hec.rs | 10 ++++------ src/internal_events/statsd_sink.rs | 5 ++--- src/internal_events/tag_cardinality_limit.rs | 5 ++--- src/internal_events/tcp.rs | 5 ++--- src/internal_events/template.rs | 5 ++--- src/internal_events/throttle.rs | 5 ++--- src/internal_events/udp.rs | 5 ++--- src/internal_events/unix.rs | 5 ++--- src/internal_events/websocket.rs | 4 ++-- src/internal_events/websocket_server.rs | 4 ++-- src/internal_events/windows.rs | 5 ++--- src/internal_events/windows_event_log.rs | 4 ++-- 72 files changed, 149 insertions(+), 197 deletions(-) diff --git a/lib/vector-lib/src/lib.rs b/lib/vector-lib/src/lib.rs index 82bb67cf9afce..277d28df18e92 100644 --- a/lib/vector-lib/src/lib.rs +++ b/lib/vector-lib/src/lib.rs @@ -11,9 +11,9 @@ pub use vector_buffers as buffers; pub use vector_common::event_test_util; pub use vector_common::{ Error, NamedInternalEvent, Result, TimeZone, assert_event_data_eq, atomic, btreemap, - byte_size_of, byte_size_of::ByteSizeOf, conversion, encode_logfmt, finalization, finalizer, id, - impl_event_data_eq, internal_event, json_size, registered_event, request_metadata, - sensitive_string, shutdown, stats, trigger, + byte_size_of, byte_size_of::ByteSizeOf, conversion, counter, encode_logfmt, finalization, + finalizer, gauge, histogram, id, impl_event_data_eq, internal_event, json_size, + registered_event, request_metadata, sensitive_string, shutdown, stats, trigger, }; pub use vector_config as configurable; pub use vector_config::impl_generate_config_from_default; diff --git a/src/internal_events/adaptive_concurrency.rs b/src/internal_events/adaptive_concurrency.rs index 2aeb9692a9a58..0d6b09026f962 100644 --- a/src/internal_events/adaptive_concurrency.rs +++ b/src/internal_events/adaptive_concurrency.rs @@ -1,7 +1,8 @@ use std::time::Duration; use metrics::Histogram; -use vector_common::histogram; +use vector_lib::histogram; +use vector_lib::internal_event::MetricName; #[derive(Clone, Copy)] pub struct AdaptiveConcurrencyLimitData { diff --git a/src/internal_events/aggregate.rs b/src/internal_events/aggregate.rs index 7e36a2f85abb9..aee7d0bc6bdac 100644 --- a/src/internal_events/aggregate.rs +++ b/src/internal_events/aggregate.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct AggregateEventRecorded; diff --git a/src/internal_events/amqp.rs b/src/internal_events/amqp.rs index 3e7891a8d1381..d6294c5ad8ade 100644 --- a/src/internal_events/amqp.rs +++ b/src/internal_events/amqp.rs @@ -1,8 +1,7 @@ #[cfg(feature = "sources-amqp")] pub mod source { - use vector_common::counter; - use vector_lib::NamedInternalEvent; - use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; + use vector_lib::{NamedInternalEvent, counter}; + use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct AmqpBytesReceived { diff --git a/src/internal_events/apache_metrics.rs b/src/internal_events/apache_metrics.rs index 624c03772bbfb..54ead6e4ae057 100644 --- a/src/internal_events/apache_metrics.rs +++ b/src/internal_events/apache_metrics.rs @@ -1,7 +1,7 @@ -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/api.rs b/src/internal_events/api.rs index ae6cf5a2de147..bae96b9d34281 100644 --- a/src/internal_events/api.rs +++ b/src/internal_events/api.rs @@ -1,8 +1,7 @@ use std::net::SocketAddr; -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct ApiStarted { diff --git a/src/internal_events/aws.rs b/src/internal_events/aws.rs index 569171b447dc6..5d29fb584fe80 100644 --- a/src/internal_events/aws.rs +++ b/src/internal_events/aws.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(NamedInternalEvent)] pub struct AwsBytesSent { diff --git a/src/internal_events/aws_cloudwatch_logs.rs b/src/internal_events/aws_cloudwatch_logs.rs index fe2b9345d7d61..f206c896505c0 100644 --- a/src/internal_events/aws_cloudwatch_logs.rs +++ b/src/internal_events/aws_cloudwatch_logs.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/aws_ec2_metadata.rs b/src/internal_events/aws_ec2_metadata.rs index 9351efb8b3677..92a76a95d46b6 100644 --- a/src/internal_events/aws_ec2_metadata.rs +++ b/src/internal_events/aws_ec2_metadata.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct AwsEc2MetadataRefreshSuccessful; diff --git a/src/internal_events/aws_ecs_metrics.rs b/src/internal_events/aws_ecs_metrics.rs index c50a096f66e11..45028dc3b6b8f 100644 --- a/src/internal_events/aws_ecs_metrics.rs +++ b/src/internal_events/aws_ecs_metrics.rs @@ -1,9 +1,9 @@ use std::borrow::Cow; -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/aws_kinesis.rs b/src/internal_events/aws_kinesis.rs index 0d0f71bfa0a07..79ff749b51ccf 100644 --- a/src/internal_events/aws_kinesis.rs +++ b/src/internal_events/aws_kinesis.rs @@ -1,8 +1,8 @@ -/// Used in both `aws_kinesis_streams` and `aws_kinesis_firehose` sinks -use vector_common::counter; use vector_lib::NamedInternalEvent; +/// Used in both `aws_kinesis_streams` and `aws_kinesis_firehose` sinks +use vector_lib::counter; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/aws_kinesis_firehose.rs b/src/internal_events/aws_kinesis_firehose.rs index 1edb3d1baa3aa..05ddd66b4dee1 100644 --- a/src/internal_events/aws_kinesis_firehose.rs +++ b/src/internal_events/aws_kinesis_firehose.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use super::prelude::{http_error_code, io_error_code}; use crate::sources::aws_kinesis_firehose::Compression; diff --git a/src/internal_events/aws_sqs.rs b/src/internal_events/aws_sqs.rs index e98696c717c6c..45bfac02c85bd 100644 --- a/src/internal_events/aws_sqs.rs +++ b/src/internal_events/aws_sqs.rs @@ -2,9 +2,9 @@ #[cfg(feature = "sources-aws_s3")] pub use s3::*; -use vector_common::counter; +use vector_lib::counter; #[cfg(any(feature = "sources-aws_s3", feature = "sources-aws_sqs"))] -use vector_lib::internal_event::{error_stage, error_type}; +use vector_lib::internal_event::{MetricName, error_stage, error_type}; use vector_lib::{NamedInternalEvent, internal_event::InternalEvent}; #[cfg(feature = "sources-aws_s3")] @@ -15,7 +15,7 @@ mod s3 { BatchResultErrorEntry, DeleteMessageBatchRequestEntry, DeleteMessageBatchResultEntry, SendMessageBatchRequestEntry, SendMessageBatchResultEntry, }; - use vector_common::histogram; + use vector_lib::histogram; use super::*; use crate::sources::aws_s3::sqs::ProcessingError; diff --git a/src/internal_events/batch.rs b/src/internal_events/batch.rs index 8eb004c6ee3f7..4f1fba482f842 100644 --- a/src/internal_events/batch.rs +++ b/src/internal_events/batch.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/common.rs b/src/internal_events/common.rs index 8254c15eb8c86..3a7eef089f230 100644 --- a/src/internal_events/common.rs +++ b/src/internal_events/common.rs @@ -1,11 +1,11 @@ use std::time::Instant; -use vector_common::{counter, histogram}; use vector_lib::NamedInternalEvent; pub use vector_lib::internal_event::EventsReceived; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{counter, histogram}; #[derive(Debug, NamedInternalEvent)] pub struct EndpointBytesReceived<'a> { diff --git a/src/internal_events/conditions.rs b/src/internal_events/conditions.rs index f41acca5fb8c7..fc1abbc3f0e47 100644 --- a/src/internal_events/conditions.rs +++ b/src/internal_events/conditions.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, Copy, Clone, NamedInternalEvent)] pub struct VrlConditionExecutionError<'a> { diff --git a/src/internal_events/datadog_agent.rs b/src/internal_events/datadog_agent.rs index 80d84b94ab325..6f6e8038dc60b 100644 --- a/src/internal_events/datadog_agent.rs +++ b/src/internal_events/datadog_agent.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct DatadogAgentJsonParseError<'a> { diff --git a/src/internal_events/datadog_metrics.rs b/src/internal_events/datadog_metrics.rs index 8e01ef3ab36aa..69414003404dc 100644 --- a/src/internal_events/datadog_metrics.rs +++ b/src/internal_events/datadog_metrics.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/datadog_traces.rs b/src/internal_events/datadog_traces.rs index 29bf957334c11..fdd48ad427d95 100644 --- a/src/internal_events/datadog_traces.rs +++ b/src/internal_events/datadog_traces.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/dnstap.rs b/src/internal_events/dnstap.rs index 1870280ce5f7b..7dd21fc5a1ca5 100644 --- a/src/internal_events/dnstap.rs +++ b/src/internal_events/dnstap.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub(crate) struct DnstapParseError { diff --git a/src/internal_events/docker_logs.rs b/src/internal_events/docker_logs.rs index 85ec380c30404..ae7809aebc0c0 100644 --- a/src/internal_events/docker_logs.rs +++ b/src/internal_events/docker_logs.rs @@ -1,9 +1,9 @@ use bollard::errors::Error; use chrono::ParseError; -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/doris.rs b/src/internal_events/doris.rs index 142a38e3343c8..7ebff3540e89e 100644 --- a/src/internal_events/doris.rs +++ b/src/internal_events/doris.rs @@ -1,5 +1,4 @@ -use vector_common::counter; -use vector_lib::{NamedInternalEvent, internal_event::InternalEvent}; +use vector_lib::{NamedInternalEvent, counter, internal_event::{InternalEvent, MetricName}}; /// Emitted when rows are successfully loaded into Doris. #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/encoding_transcode.rs b/src/internal_events/encoding_transcode.rs index 91b969074cfd6..d1fc3ebe1f91d 100644 --- a/src/internal_events/encoding_transcode.rs +++ b/src/internal_events/encoding_transcode.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct DecoderBomRemoval { diff --git a/src/internal_events/eventstoredb_metrics.rs b/src/internal_events/eventstoredb_metrics.rs index 3efc903477980..650282793d279 100644 --- a/src/internal_events/eventstoredb_metrics.rs +++ b/src/internal_events/eventstoredb_metrics.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct EventStoreDbMetricsHttpError { diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index 8dfb266dec1dd..fd573031b7f4e 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -1,14 +1,14 @@ use std::time::Duration; use tokio::time::error::Elapsed; -use vector_common::{counter, histogram}; use vector_lib::{ NamedInternalEvent, internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; +use vector_lib::{counter, histogram}; use super::prelude::io_error_code; diff --git a/src/internal_events/expansion.rs b/src/internal_events/expansion.rs index 22d13ab60671b..568fcc0da7da1 100644 --- a/src/internal_events/expansion.rs +++ b/src/internal_events/expansion.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(NamedInternalEvent)] diff --git a/src/internal_events/file.rs b/src/internal_events/file.rs index 3cf36051376da..86b502f1273b0 100644 --- a/src/internal_events/file.rs +++ b/src/internal_events/file.rs @@ -2,14 +2,14 @@ use std::borrow::Cow; -use vector_common::{counter, gauge}; use vector_lib::{ NamedInternalEvent, configurable::configurable_component, internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }, }; +use vector_lib::{counter, gauge}; #[cfg(any(feature = "sources-file", feature = "sources-kubernetes_logs"))] pub use self::source::*; @@ -110,11 +110,11 @@ mod source { use std::{io::Error, path::Path, time::Duration}; use bytes::BytesMut; - use vector_common::counter; + use vector_lib::counter; use vector_lib::{ NamedInternalEvent, emit, file_source_common::internal_events::FileSourceInternalEvents, - internal_event::{ComponentEventsDropped, INTENTIONAL, error_stage, error_type}, + internal_event::{ComponentEventsDropped, INTENTIONAL, MetricName, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/file_descriptor.rs b/src/internal_events/file_descriptor.rs index c328a9b9e5578..7ed87349946b0 100644 --- a/src/internal_events/file_descriptor.rs +++ b/src/internal_events/file_descriptor.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct FileDescriptorReadError { diff --git a/src/internal_events/fluent.rs b/src/internal_events/fluent.rs index c1dff26be877e..7c8ce8d23d9ce 100644 --- a/src/internal_events/fluent.rs +++ b/src/internal_events/fluent.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use crate::sources::fluent::DecodeError; diff --git a/src/internal_events/gcp_pubsub.rs b/src/internal_events/gcp_pubsub.rs index 52930c099b0f0..8c70dfd98120a 100644 --- a/src/internal_events/gcp_pubsub.rs +++ b/src/internal_events/gcp_pubsub.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(NamedInternalEvent)] pub struct GcpPubsubConnectError { diff --git a/src/internal_events/grpc.rs b/src/internal_events/grpc.rs index ab66a0554de4b..93b948942ff79 100644 --- a/src/internal_events/grpc.rs +++ b/src/internal_events/grpc.rs @@ -2,9 +2,9 @@ use std::time::Duration; use http::response::Response; use tonic::Code; -use vector_common::{counter, histogram}; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::{counter, histogram}; const GRPC_STATUS_LABEL: &str = "grpc_status"; diff --git a/src/internal_events/heartbeat.rs b/src/internal_events/heartbeat.rs index 7458a1bb88140..008f8cb18dbd8 100644 --- a/src/internal_events/heartbeat.rs +++ b/src/internal_events/heartbeat.rs @@ -1,8 +1,7 @@ use std::time::Instant; -use vector_common::gauge; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::{NamedInternalEvent, gauge}; +use vector_lib::internal_event::{InternalEvent, MetricName}; use crate::built_info; diff --git a/src/internal_events/host_metrics.rs b/src/internal_events/host_metrics.rs index 382f689f890e9..25b3bb3558d69 100644 --- a/src/internal_events/host_metrics.rs +++ b/src/internal_events/host_metrics.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct HostMetricsScrapeError { diff --git a/src/internal_events/http.rs b/src/internal_events/http.rs index 8a724b9f6b447..3dcc203dc9145 100644 --- a/src/internal_events/http.rs +++ b/src/internal_events/http.rs @@ -1,12 +1,12 @@ use std::{error::Error, time::Duration}; use http::Response; -use vector_common::{counter, histogram}; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; +use vector_lib::{counter, histogram}; const HTTP_STATUS_LABEL: &str = "status"; diff --git a/src/internal_events/http_client.rs b/src/internal_events/http_client.rs index eeffe87565cbf..d0e92c25b15e8 100644 --- a/src/internal_events/http_client.rs +++ b/src/internal_events/http_client.rs @@ -5,9 +5,9 @@ use http::{ header::{self, HeaderMap, HeaderValue}, }; use hyper::{Error, body::HttpBody}; -use vector_common::{counter, histogram}; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::{counter, histogram}; #[derive(Debug, NamedInternalEvent)] pub struct AboutToSendHttpRequest<'a, T> { diff --git a/src/internal_events/http_client_source.rs b/src/internal_events/http_client_source.rs index 1874ea18c8c44..c6260d97d5899 100644 --- a/src/internal_events/http_client_source.rs +++ b/src/internal_events/http_client_source.rs @@ -1,9 +1,9 @@ #![allow(dead_code)] // TODO requires optional feature compilation -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/influxdb.rs b/src/internal_events/influxdb.rs index 78eb60c0f6281..adf713eb43f6e 100644 --- a/src/internal_events/influxdb.rs +++ b/src/internal_events/influxdb.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/internal_logs.rs b/src/internal_events/internal_logs.rs index de0d68f3e65e8..09ab5abaa5c3a 100644 --- a/src/internal_events/internal_logs.rs +++ b/src/internal_events/internal_logs.rs @@ -1,5 +1,4 @@ -use vector_common::counter; -use vector_lib::{NamedInternalEvent, internal_event::InternalEvent, json_size::JsonSize}; +use vector_lib::{NamedInternalEvent, counter, internal_event::{InternalEvent, MetricName}, json_size::JsonSize}; #[derive(Debug, NamedInternalEvent)] pub struct InternalLogsBytesReceived { diff --git a/src/internal_events/journald.rs b/src/internal_events/journald.rs index 192833b9f533d..b0e4f23aca105 100644 --- a/src/internal_events/journald.rs +++ b/src/internal_events/journald.rs @@ -1,8 +1,8 @@ -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, codecs::decoding::BoxedFramingError, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/kafka.rs b/src/internal_events/kafka.rs index 0847ecbad1cba..0415f809808e7 100644 --- a/src/internal_events/kafka.rs +++ b/src/internal_events/kafka.rs @@ -1,11 +1,11 @@ #![allow(dead_code)] // TODO requires optional feature compilation -use vector_common::{counter, gauge}; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; +use vector_lib::{counter, gauge}; use vrl::path::OwnedTargetPath; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/kubernetes_logs.rs b/src/internal_events/kubernetes_logs.rs index d61119c1928bb..48918239e0e21 100644 --- a/src/internal_events/kubernetes_logs.rs +++ b/src/internal_events/kubernetes_logs.rs @@ -1,8 +1,8 @@ -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, internal_event::{ - ComponentEventsDropped, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; diff --git a/src/internal_events/log_to_metric.rs b/src/internal_events/log_to_metric.rs index 77ac2a6cc7375..51717fa0c1ffa 100644 --- a/src/internal_events/log_to_metric.rs +++ b/src/internal_events/log_to_metric.rs @@ -1,9 +1,8 @@ use std::num::ParseFloatError; -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(NamedInternalEvent)] diff --git a/src/internal_events/logplex.rs b/src/internal_events/logplex.rs index e5c9816d51796..256fe088598ed 100644 --- a/src/internal_events/logplex.rs +++ b/src/internal_events/logplex.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use super::prelude::io_error_code; diff --git a/src/internal_events/loki.rs b/src/internal_events/loki.rs index 628b5afc38dd6..70ffd98c340b2 100644 --- a/src/internal_events/loki.rs +++ b/src/internal_events/loki.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, INTENTIONAL, InternalEvent, error_stage, error_type, + ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/lua.rs b/src/internal_events/lua.rs index dc9e0a65e6058..9447d193a79d5 100644 --- a/src/internal_events/lua.rs +++ b/src/internal_events/lua.rs @@ -1,8 +1,8 @@ -use vector_common::{counter, gauge}; use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{counter, gauge}; use crate::transforms::lua::v2::BuildError; diff --git a/src/internal_events/metric_to_log.rs b/src/internal_events/metric_to_log.rs index 5c18bbc9970e3..7f8ac1a5c84da 100644 --- a/src/internal_events/metric_to_log.rs +++ b/src/internal_events/metric_to_log.rs @@ -1,8 +1,7 @@ use serde_json::Error; -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/mongodb_metrics.rs b/src/internal_events/mongodb_metrics.rs index 0df492c5ea5bf..a40c95ae86b08 100644 --- a/src/internal_events/mongodb_metrics.rs +++ b/src/internal_events/mongodb_metrics.rs @@ -1,8 +1,8 @@ use mongodb::{bson, error::Error as MongoError}; -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/mqtt.rs b/src/internal_events/mqtt.rs index c57c5fd130d13..ef08fcf28f426 100644 --- a/src/internal_events/mqtt.rs +++ b/src/internal_events/mqtt.rs @@ -1,9 +1,8 @@ use std::fmt::Debug; use rumqttc::ConnectionError; -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct MqttConnectionError { diff --git a/src/internal_events/nginx_metrics.rs b/src/internal_events/nginx_metrics.rs index d4fcd8d7cf7d7..4e4649cd539be 100644 --- a/src/internal_events/nginx_metrics.rs +++ b/src/internal_events/nginx_metrics.rs @@ -1,7 +1,7 @@ -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/open.rs b/src/internal_events/open.rs index 5fbe15817486c..a355905a135f4 100644 --- a/src/internal_events/open.rs +++ b/src/internal_events/open.rs @@ -6,9 +6,8 @@ use std::{ }, }; -use vector_common::gauge; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::{NamedInternalEvent, gauge}; +use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct ConnectionOpen { diff --git a/src/internal_events/parser.rs b/src/internal_events/parser.rs index fdd890dfd1b41..95536e9f993b0 100644 --- a/src/internal_events/parser.rs +++ b/src/internal_events/parser.rs @@ -2,10 +2,9 @@ use std::borrow::Cow; -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; fn truncate_string_at(s: &str, maxlen: usize) -> Cow<'_, str> { diff --git a/src/internal_events/postgresql_metrics.rs b/src/internal_events/postgresql_metrics.rs index 710df6203525d..8d8d478454127 100644 --- a/src/internal_events/postgresql_metrics.rs +++ b/src/internal_events/postgresql_metrics.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct PostgresqlMetricsCollectError<'a> { diff --git a/src/internal_events/process.rs b/src/internal_events/process.rs index 7c3da4d089a68..22e765c6c2315 100644 --- a/src/internal_events/process.rs +++ b/src/internal_events/process.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use crate::{built_info, config}; diff --git a/src/internal_events/prometheus.rs b/src/internal_events/prometheus.rs index a4b7b1d3878ba..bd142e06e8d6e 100644 --- a/src/internal_events/prometheus.rs +++ b/src/internal_events/prometheus.rs @@ -3,10 +3,9 @@ #[cfg(feature = "sources-prometheus-scrape")] use std::borrow::Cow; -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[cfg(feature = "sources-prometheus-scrape")] use vector_lib::prometheus::parser::ParserError; diff --git a/src/internal_events/pulsar.rs b/src/internal_events/pulsar.rs index dd2f9f3df1ddd..825d9ff3af6ba 100644 --- a/src/internal_events/pulsar.rs +++ b/src/internal_events/pulsar.rs @@ -2,10 +2,9 @@ #[cfg(feature = "sources-pulsar")] use metrics::Counter; -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/redis.rs b/src/internal_events/redis.rs index c9f94cd3a65bf..1ecfbe34574cd 100644 --- a/src/internal_events/redis.rs +++ b/src/internal_events/redis.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct RedisReceiveEventError { diff --git a/src/internal_events/reduce.rs b/src/internal_events/reduce.rs index fa9bcd56e1fb8..e9882799682ad 100644 --- a/src/internal_events/reduce.rs +++ b/src/internal_events/reduce.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use vrl::{path::PathParseError, value::KeyString}; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/remap.rs b/src/internal_events/remap.rs index 156721279717e..6c4156c0d8b90 100644 --- a/src/internal_events/remap.rs +++ b/src/internal_events/remap.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/sematext_metrics.rs b/src/internal_events/sematext_metrics.rs index ded18044fd26c..cfff591fff8ab 100644 --- a/src/internal_events/sematext_metrics.rs +++ b/src/internal_events/sematext_metrics.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; use crate::event::metric::Metric; diff --git a/src/internal_events/socket.rs b/src/internal_events/socket.rs index 39d7ded04b96d..66762eb8d2fc1 100644 --- a/src/internal_events/socket.rs +++ b/src/internal_events/socket.rs @@ -1,13 +1,13 @@ use std::net::Ipv4Addr; -use vector_common::{counter, histogram}; use vector_lib::{ NamedInternalEvent, internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; +use vector_lib::{counter, histogram}; #[derive(Debug, Clone, Copy, Eq, PartialEq)] #[allow(dead_code)] // some features only use some variants diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index e26f1a165e647..95a1336577f86 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -7,11 +7,10 @@ pub use self::source::*; #[cfg(feature = "sinks-splunk_hec")] mod sink { - use metrics::{counter, gauge}; use serde_json::Error; - use vector_lib::NamedInternalEvent; + use vector_lib::{NamedInternalEvent, counter, gauge}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; use crate::{ @@ -197,9 +196,8 @@ mod sink { #[cfg(feature = "sources-splunk_hec")] mod source { - use vector_common::counter; - use vector_lib::NamedInternalEvent; - use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; + use vector_lib::{NamedInternalEvent, counter}; + use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use crate::sources::splunk_hec::ApiError; diff --git a/src/internal_events/statsd_sink.rs b/src/internal_events/statsd_sink.rs index 6de9366d8fc79..a80acf0c4225b 100644 --- a/src/internal_events/statsd_sink.rs +++ b/src/internal_events/statsd_sink.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; use crate::event::metric::{MetricKind, MetricValue}; diff --git a/src/internal_events/tag_cardinality_limit.rs b/src/internal_events/tag_cardinality_limit.rs index 3441e5ab679d6..2498bc6aa8724 100644 --- a/src/internal_events/tag_cardinality_limit.rs +++ b/src/internal_events/tag_cardinality_limit.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName}; #[derive(NamedInternalEvent)] pub struct TagCardinalityLimitRejectingEvent<'a> { diff --git a/src/internal_events/tcp.rs b/src/internal_events/tcp.rs index b813e55ab155d..0bc3d751c6509 100644 --- a/src/internal_events/tcp.rs +++ b/src/internal_events/tcp.rs @@ -1,8 +1,7 @@ use std::net::SocketAddr; -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use crate::{internal_events::SocketOutgoingConnectionError, tls::TlsError}; diff --git a/src/internal_events/template.rs b/src/internal_events/template.rs index a482ebd638f59..7e5bab163dab9 100644 --- a/src/internal_events/template.rs +++ b/src/internal_events/template.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; #[derive(NamedInternalEvent)] diff --git a/src/internal_events/throttle.rs b/src/internal_events/throttle.rs index 81ca220976eef..b684dc3df77d1 100644 --- a/src/internal_events/throttle.rs +++ b/src/internal_events/throttle.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub(crate) struct ThrottleEventDiscarded { diff --git a/src/internal_events/udp.rs b/src/internal_events/udp.rs index 9b83143c9bdd3..e91d00b9a3e65 100644 --- a/src/internal_events/udp.rs +++ b/src/internal_events/udp.rs @@ -1,7 +1,6 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; use crate::internal_events::SocketOutgoingConnectionError; diff --git a/src/internal_events/unix.rs b/src/internal_events/unix.rs index ff429a8cec5d7..c0709e90b2baf 100644 --- a/src/internal_events/unix.rs +++ b/src/internal_events/unix.rs @@ -2,10 +2,9 @@ use std::{io::Error, path::Path}; -use vector_common::counter; -use vector_lib::NamedInternalEvent; +use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, }; use crate::internal_events::SocketOutgoingConnectionError; diff --git a/src/internal_events/websocket.rs b/src/internal_events/websocket.rs index 71f3c8a8e7ba9..892eba3ecf3b0 100644 --- a/src/internal_events/websocket.rs +++ b/src/internal_events/websocket.rs @@ -6,13 +6,13 @@ use std::{ }; use tokio_tungstenite::tungstenite::error::Error as TungsteniteError; -use vector_common::{counter, histogram}; use vector_common::{ internal_event::{error_stage, error_type}, json_size::JsonSize, }; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::internal_event::{InternalEvent, MetricName}; +use vector_lib::{counter, histogram}; pub const PROTOCOL: &str = "websocket"; diff --git a/src/internal_events/websocket_server.rs b/src/internal_events/websocket_server.rs index b6dcebd45a0b5..0c543ad56eee0 100644 --- a/src/internal_events/websocket_server.rs +++ b/src/internal_events/websocket_server.rs @@ -1,8 +1,8 @@ use std::{error::Error, fmt::Debug}; -use vector_common::{counter, gauge}; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::{counter, gauge}; #[derive(Debug, NamedInternalEvent)] pub struct WebSocketListenerConnectionEstablished { diff --git a/src/internal_events/windows.rs b/src/internal_events/windows.rs index 41c8491b6d961..b660a350810ba 100644 --- a/src/internal_events/windows.rs +++ b/src/internal_events/windows.rs @@ -1,6 +1,5 @@ -use vector_common::counter; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct WindowsServiceStart<'a> { diff --git a/src/internal_events/windows_event_log.rs b/src/internal_events/windows_event_log.rs index 77d43979bb6ae..1e406d8ef3c30 100644 --- a/src/internal_events/windows_event_log.rs +++ b/src/internal_events/windows_event_log.rs @@ -1,8 +1,8 @@ use tracing::error; -use vector_common::counter; +use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, error_stage, error_type}, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, }; #[derive(Debug, NamedInternalEvent)] From 8852c648baf561152b7213de1224ebbe6d0299a5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 18:46:54 -0400 Subject: [PATCH 06/17] Use MetricName in k8s --- lib/vector-common/src/internal_event/metric_name.rs | 8 ++++++++ src/internal_events/kubernetes_logs.rs | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs index 93879c2fcb180..950e48cff0e57 100644 --- a/lib/vector-common/src/internal_event/metric_name.rs +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -126,6 +126,10 @@ pub enum MetricName { WindowsServiceStartTotal, WindowsServiceStopTotal, WindowsServiceUninstallTotal, + K8sEventNamespaceAnnotationFailuresTotal, + K8sEventNodeAnnotationFailuresTotal, + K8sFormatPickerEdgeCasesTotal, + K8sDockerFormatParseFailuresTotal, } impl MetricName { @@ -257,6 +261,10 @@ impl MetricName { Self::WindowsServiceStartTotal => "windows_service_start_total", Self::WindowsServiceStopTotal => "windows_service_stop_total", Self::WindowsServiceUninstallTotal => "windows_service_uninstall_total", + Self::K8sEventNamespaceAnnotationFailuresTotal => "k8s_event_namespace_annotation_failures_total", + Self::K8sEventNodeAnnotationFailuresTotal => "k8s_event_node_annotation_failures_total", + Self::K8sFormatPickerEdgeCasesTotal => "k8s_format_picker_edge_cases_total", + Self::K8sDockerFormatParseFailuresTotal => "k8s_docker_format_parse_failures_total", } } } diff --git a/src/internal_events/kubernetes_logs.rs b/src/internal_events/kubernetes_logs.rs index 48918239e0e21..cd21435ccbfc8 100644 --- a/src/internal_events/kubernetes_logs.rs +++ b/src/internal_events/kubernetes_logs.rs @@ -105,7 +105,7 @@ impl InternalEvent for KubernetesLogsEventNamespaceAnnotationError<'_> { "stage" => error_stage::PROCESSING, ) .increment(1); - counter!("k8s_event_namespace_annotation_failures_total").increment(1); + counter!(MetricName::K8sEventNamespaceAnnotationFailuresTotal).increment(1); } } @@ -130,7 +130,7 @@ impl InternalEvent for KubernetesLogsEventNodeAnnotationError<'_> { "stage" => error_stage::PROCESSING, ) .increment(1); - counter!("k8s_event_node_annotation_failures_total").increment(1); + counter!(MetricName::K8sEventNodeAnnotationFailuresTotal).increment(1); } } @@ -145,7 +145,7 @@ impl InternalEvent for KubernetesLogsFormatPickerEdgeCase { message = "Encountered format picker edge case.", what = %self.what, ); - counter!("k8s_format_picker_edge_cases_total").increment(1); + counter!(MetricName::K8sFormatPickerEdgeCasesTotal).increment(1); } } @@ -168,7 +168,7 @@ impl InternalEvent for KubernetesLogsDockerFormatParseError<'_> { "stage" => error_stage::PROCESSING, ) .increment(1); - counter!("k8s_docker_format_parse_failures_total").increment(1); + counter!(MetricName::K8sDockerFormatParseFailuresTotal).increment(1); } } From ce7400a4dd73533909eecbe71ed2b9fb47c6cdfc Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 18:49:03 -0400 Subject: [PATCH 07/17] Use MetricName in aws_sqs --- lib/vector-common/src/internal_event/metric_name.rs | 7 +++++++ src/internal_events/aws_sqs.rs | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs index 950e48cff0e57..8581df37e15d9 100644 --- a/lib/vector-common/src/internal_event/metric_name.rs +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -130,9 +130,13 @@ pub enum MetricName { K8sEventNodeAnnotationFailuresTotal, K8sFormatPickerEdgeCasesTotal, K8sDockerFormatParseFailuresTotal, + S3ObjectProcessingSucceededDurationSeconds, + S3ObjectProcessingFailedDurationSeconds, + SqsS3EventRecordIgnoredTotal, } impl MetricName { + #[allow(clippy::too_many_lines)] #[must_use] pub const fn as_str(self) -> &'static str { match self { @@ -265,6 +269,9 @@ impl MetricName { Self::K8sEventNodeAnnotationFailuresTotal => "k8s_event_node_annotation_failures_total", Self::K8sFormatPickerEdgeCasesTotal => "k8s_format_picker_edge_cases_total", Self::K8sDockerFormatParseFailuresTotal => "k8s_docker_format_parse_failures_total", + Self::S3ObjectProcessingSucceededDurationSeconds => "s3_object_processing_succeeded_duration_seconds", + Self::S3ObjectProcessingFailedDurationSeconds => "s3_object_processing_failed_duration_seconds", + Self::SqsS3EventRecordIgnoredTotal => "sqs_s3_event_record_ignored_total", } } } diff --git a/src/internal_events/aws_sqs.rs b/src/internal_events/aws_sqs.rs index 45bfac02c85bd..94f42eff52530 100644 --- a/src/internal_events/aws_sqs.rs +++ b/src/internal_events/aws_sqs.rs @@ -34,7 +34,7 @@ mod s3 { duration_ms = %self.duration.as_millis(), ); histogram!( - "s3_object_processing_succeeded_duration_seconds", + MetricName::S3ObjectProcessingSucceededDurationSeconds, "bucket" => self.bucket.to_owned(), ) .record(self.duration); @@ -55,7 +55,7 @@ mod s3 { duration_ms = %self.duration.as_millis(), ); histogram!( - "s3_object_processing_failed_duration_seconds", + MetricName::S3ObjectProcessingFailedDurationSeconds, "bucket" => self.bucket.to_owned(), ) .record(self.duration); @@ -324,7 +324,7 @@ impl InternalEvent for SqsS3EventRecordInvalidEventIgnored<'_> { fn emit(self) { warn!(message = "Ignored S3 record in SQS message for an event that was not ObjectCreated.", bucket = %self.bucket, key = %self.key, kind = %self.kind, name = %self.name); - counter!("sqs_s3_event_record_ignored_total", "ignore_type" => "invalid_event_kind") + counter!(MetricName::SqsS3EventRecordIgnoredTotal, "ignore_type" => "invalid_event_kind") .increment(1); } } From 0e4286b47157252ba4cd3f2075ce92d26b06dab3 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 30 Apr 2026 19:09:08 -0400 Subject: [PATCH 08/17] Use EventName everywhere and make clippy pass --- benches/metrics_snapshot.rs | 1 + .../src/internal_event/metric_name.rs | 24 ++++++++++++++ .../memory/internal_events.rs | 31 ++++++++++--------- src/internal_telemetry/allocations/mod.rs | 10 +++--- src/sources/internal_metrics.rs | 1 + src/topology/builder.rs | 8 ++--- src/utilization.rs | 1 + 7 files changed, 52 insertions(+), 24 deletions(-) diff --git a/benches/metrics_snapshot.rs b/benches/metrics_snapshot.rs index 279911e5e65a4..ae9e7603307f3 100644 --- a/benches/metrics_snapshot.rs +++ b/benches/metrics_snapshot.rs @@ -17,6 +17,7 @@ fn benchmark(c: &mut Criterion) { group.finish(); } +#[allow(clippy::disallowed_macros)] fn prepare_metrics(cardinality: usize) -> &'static vector::metrics::Controller { vector::metrics::init_test(); let controller = vector::metrics::Controller::get().unwrap(); diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs index 8581df37e15d9..459667ec46005 100644 --- a/lib/vector-common/src/internal_event/metric_name.rs +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -133,6 +133,18 @@ pub enum MetricName { S3ObjectProcessingSucceededDurationSeconds, S3ObjectProcessingFailedDurationSeconds, SqsS3EventRecordIgnoredTotal, + ComponentAllocatedBytesTotal, + ComponentDeallocatedBytesTotal, + ComponentAllocatedBytes, + Utilization, + MemoryEnrichmentTableByteSize, + MemoryEnrichmentTableFailedInsertions, + MemoryEnrichmentTableFailedReads, + MemoryEnrichmentTableFlushesTotal, + MemoryEnrichmentTableInsertionsTotal, + MemoryEnrichmentTableObjectsCount, + MemoryEnrichmentTableReadsTotal, + MemoryEnrichmentTableTtlExpirations, } impl MetricName { @@ -272,6 +284,18 @@ impl MetricName { Self::S3ObjectProcessingSucceededDurationSeconds => "s3_object_processing_succeeded_duration_seconds", Self::S3ObjectProcessingFailedDurationSeconds => "s3_object_processing_failed_duration_seconds", Self::SqsS3EventRecordIgnoredTotal => "sqs_s3_event_record_ignored_total", + Self::ComponentAllocatedBytesTotal => "component_allocated_bytes_total", + Self::ComponentDeallocatedBytesTotal => "component_deallocated_bytes_total", + Self::ComponentAllocatedBytes => "component_allocated_bytes", + Self::Utilization => "utilization", + Self::MemoryEnrichmentTableByteSize => "memory_enrichment_table_byte_size", + Self::MemoryEnrichmentTableFailedInsertions => "memory_enrichment_table_failed_insertions", + Self::MemoryEnrichmentTableFailedReads => "memory_enrichment_table_failed_reads", + Self::MemoryEnrichmentTableFlushesTotal => "memory_enrichment_table_flushes_total", + Self::MemoryEnrichmentTableInsertionsTotal => "memory_enrichment_table_insertions_total", + Self::MemoryEnrichmentTableObjectsCount => "memory_enrichment_table_objects_count", + Self::MemoryEnrichmentTableReadsTotal => "memory_enrichment_table_reads_total", + Self::MemoryEnrichmentTableTtlExpirations => "memory_enrichment_table_ttl_expirations", } } } diff --git a/src/enrichment_tables/memory/internal_events.rs b/src/enrichment_tables/memory/internal_events.rs index 0799c6662a6af..becbfd4146bb1 100644 --- a/src/enrichment_tables/memory/internal_events.rs +++ b/src/enrichment_tables/memory/internal_events.rs @@ -1,6 +1,7 @@ -use metrics::{counter, gauge}; use vector_lib::{ - NamedInternalEvent, configurable::configurable_component, internal_event::InternalEvent, + NamedInternalEvent, configurable::configurable_component, + counter, gauge, + internal_event::{InternalEvent, MetricName}, }; /// Configuration of internal metrics for enrichment memory table. @@ -26,12 +27,12 @@ impl InternalEvent for MemoryEnrichmentTableRead<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - "memory_enrichment_table_reads_total", + MetricName::MemoryEnrichmentTableReadsTotal, "key" => self.key.to_owned() ) .increment(1); } else { - counter!("memory_enrichment_table_reads_total",).increment(1); + counter!(MetricName::MemoryEnrichmentTableReadsTotal,).increment(1); } } } @@ -46,12 +47,12 @@ impl InternalEvent for MemoryEnrichmentTableInserted<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - "memory_enrichment_table_insertions_total", + MetricName::MemoryEnrichmentTableInsertionsTotal, "key" => self.key.to_owned() ) .increment(1); } else { - counter!("memory_enrichment_table_insertions_total",).increment(1); + counter!(MetricName::MemoryEnrichmentTableInsertionsTotal,).increment(1); } } } @@ -64,9 +65,9 @@ pub(crate) struct MemoryEnrichmentTableFlushed { impl InternalEvent for MemoryEnrichmentTableFlushed { fn emit(self) { - counter!("memory_enrichment_table_flushes_total",).increment(1); - gauge!("memory_enrichment_table_objects_count",).set(self.new_objects_count as f64); - gauge!("memory_enrichment_table_byte_size",).set(self.new_byte_size as f64); + counter!(MetricName::MemoryEnrichmentTableFlushesTotal,).increment(1); + gauge!(MetricName::MemoryEnrichmentTableObjectsCount,).set(self.new_objects_count as f64); + gauge!(MetricName::MemoryEnrichmentTableByteSize,).set(self.new_byte_size as f64); } } @@ -80,12 +81,12 @@ impl InternalEvent for MemoryEnrichmentTableTtlExpired<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - "memory_enrichment_table_ttl_expirations", + MetricName::MemoryEnrichmentTableTtlExpirations, "key" => self.key.to_owned() ) .increment(1); } else { - counter!("memory_enrichment_table_ttl_expirations",).increment(1); + counter!(MetricName::MemoryEnrichmentTableTtlExpirations,).increment(1); } } } @@ -100,12 +101,12 @@ impl InternalEvent for MemoryEnrichmentTableReadFailed<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - "memory_enrichment_table_failed_reads", + MetricName::MemoryEnrichmentTableFailedReads, "key" => self.key.to_owned() ) .increment(1); } else { - counter!("memory_enrichment_table_failed_reads",).increment(1); + counter!(MetricName::MemoryEnrichmentTableFailedReads,).increment(1); } } } @@ -120,12 +121,12 @@ impl InternalEvent for MemoryEnrichmentTableInsertFailed<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - "memory_enrichment_table_failed_insertions", + MetricName::MemoryEnrichmentTableFailedInsertions, "key" => self.key.to_owned() ) .increment(1); } else { - counter!("memory_enrichment_table_failed_insertions",).increment(1); + counter!(MetricName::MemoryEnrichmentTableFailedInsertions,).increment(1); } } } diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index a2680256ec167..4d5c87b83bcc7 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -11,7 +11,7 @@ use std::{ }; use arr_macro::arr; -use metrics::{counter, gauge}; +use vector_common::{counter, gauge, internal_event::MetricName}; use rand_distr::num_traits::ToPrimitive; use self::allocator::Tracer; @@ -144,26 +144,26 @@ pub fn init_allocation_tracing() { let group_info = group.lock().unwrap(); if allocations_diff > 0 { counter!( - "component_allocated_bytes_total", "component_kind" => group_info.component_kind.clone(), + MetricName::ComponentAllocatedBytesTotal, "component_kind" => group_info.component_kind.clone(), "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone()).increment(allocations_diff); } if deallocations_diff > 0 { counter!( - "component_deallocated_bytes_total", "component_kind" => group_info.component_kind.clone(), + MetricName::ComponentDeallocatedBytesTotal, "component_kind" => group_info.component_kind.clone(), "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone()).increment(deallocations_diff); } if mem_used_diff > 0 { gauge!( - "component_allocated_bytes", "component_type" => group_info.component_type.clone(), + MetricName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone(), "component_kind" => group_info.component_kind.clone()) .increment(mem_used_diff.to_f64().expect("failed to convert mem_used from int to float")); } if mem_used_diff < 0 { gauge!( - "component_allocated_bytes", "component_type" => group_info.component_type.clone(), + MetricName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone(), "component_kind" => group_info.component_kind.clone()) .decrement(-mem_used_diff.to_f64().expect("failed to convert mem_used from int to float")); diff --git a/src/sources/internal_metrics.rs b/src/sources/internal_metrics.rs index f576efa2a71a1..1302072ea88c3 100644 --- a/src/sources/internal_metrics.rs +++ b/src/sources/internal_metrics.rs @@ -194,6 +194,7 @@ impl InternalMetrics<'_> { #[cfg(test)] mod tests { + #![allow(clippy::disallowed_macros)] use std::collections::BTreeMap; use metrics::{counter, gauge, histogram}; diff --git a/src/topology/builder.rs b/src/topology/builder.rs index 8948109fa7fb7..fed8740646eb3 100644 --- a/src/topology/builder.rs +++ b/src/topology/builder.rs @@ -8,7 +8,7 @@ use std::{ use futures::{FutureExt, StreamExt, TryStreamExt, stream::FuturesOrdered}; use futures_util::stream::FuturesUnordered; -use metrics::gauge; +use vector_lib::{gauge, internal_event::MetricName}; use stream_cancel::{StreamExt as StreamCancelExt, Trigger, Tripwire}; use tokio::{ select, @@ -627,7 +627,7 @@ impl<'a> Builder<'a> { let utilization_sender = self .utilization_registry - .add_component(key.clone(), gauge!("utilization")); + .add_component(key.clone(), gauge!(MetricName::Utilization)); let component_key = key.clone(); let sink = async move { debug!("Sink starting."); @@ -747,7 +747,7 @@ impl<'a> Builder<'a> { let sender = self .utilization_registry - .add_component(node.key.clone(), gauge!("utilization")); + .add_component(node.key.clone(), gauge!(MetricName::Utilization)); let runner = Runner::new( t, input_rx, @@ -803,7 +803,7 @@ impl<'a> Builder<'a> { let sender = self .utilization_registry - .add_component(key.clone(), gauge!("utilization")); + .add_component(key.clone(), gauge!(MetricName::Utilization)); let output_sender = sender.clone(); let input_rx = Utilization::new(sender, key.clone(), input_rx.into_stream()); diff --git a/src/utilization.rs b/src/utilization.rs index b3496b998f1c5..f623837899d57 100644 --- a/src/utilization.rs +++ b/src/utilization.rs @@ -342,6 +342,7 @@ impl OutputUtilization { #[cfg(test)] mod tests { + #![allow(clippy::disallowed_macros)] use mock_instant::global::MockClock; use serial_test::serial; From 2e7ac46e372cfff1adb28c7d2cf06a1a912d1edd Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 10:40:24 -0400 Subject: [PATCH 09/17] Separate MetricName -> CounterName/GaugeName/HistogramName --- lib/codecs/src/internal_events.rs | 22 ++-- lib/vector-buffers/src/internal_events.rs | 50 ++++---- .../src/internal_event/bytes_received.rs | 4 +- .../src/internal_event/bytes_sent.rs | 4 +- .../component_events_dropped.rs | 4 +- .../component_events_timed_out.rs | 6 +- .../src/internal_event/events_received.rs | 8 +- .../src/internal_event/events_sent.rs | 14 +-- .../src/internal_event/metric_name.rs | 110 ++++++++++++------ lib/vector-common/src/internal_event/mod.rs | 2 +- .../src/internal_event/service.rs | 6 +- lib/vector-common/src/lib.rs | 12 +- lib/vector-core/src/latency.rs | 6 +- lib/vector-core/src/source_sender/mod.rs | 8 +- .../memory/internal_events.rs | 31 ++--- src/internal_events/adaptive_concurrency.rs | 16 +-- src/internal_events/aggregate.rs | 8 +- src/internal_events/amqp.rs | 10 +- src/internal_events/apache_metrics.rs | 8 +- src/internal_events/api.rs | 4 +- src/internal_events/aws.rs | 4 +- src/internal_events/aws_cloudwatch_logs.rs | 6 +- src/internal_events/aws_ec2_metadata.rs | 8 +- src/internal_events/aws_ecs_metrics.rs | 10 +- src/internal_events/aws_kinesis.rs | 4 +- src/internal_events/aws_kinesis_firehose.rs | 6 +- src/internal_events/aws_sqs.rs | 32 ++--- src/internal_events/batch.rs | 6 +- src/internal_events/common.rs | 16 +-- src/internal_events/conditions.rs | 4 +- src/internal_events/datadog_agent.rs | 4 +- src/internal_events/datadog_metrics.rs | 6 +- src/internal_events/datadog_traces.rs | 8 +- src/internal_events/dnstap.rs | 4 +- src/internal_events/docker_logs.rs | 20 ++-- src/internal_events/doris.rs | 11 +- src/internal_events/encoding_transcode.rs | 8 +- src/internal_events/eventstoredb_metrics.rs | 6 +- src/internal_events/exec.rs | 18 +-- src/internal_events/expansion.rs | 6 +- src/internal_events/file.rs | 66 ++++++----- src/internal_events/file_descriptor.rs | 4 +- src/internal_events/fluent.rs | 4 +- src/internal_events/gcp_pubsub.rs | 8 +- src/internal_events/grpc.rs | 12 +- src/internal_events/heartbeat.rs | 6 +- src/internal_events/host_metrics.rs | 8 +- src/internal_events/http.rs | 22 ++-- src/internal_events/http_client.rs | 16 +-- src/internal_events/http_client_source.rs | 10 +- src/internal_events/influxdb.rs | 6 +- src/internal_events/internal_logs.rs | 12 +- src/internal_events/journald.rs | 12 +- src/internal_events/kafka.rs | 36 +++--- src/internal_events/kubernetes_logs.rs | 31 ++--- src/internal_events/log_to_metric.rs | 12 +- src/internal_events/logplex.rs | 4 +- src/internal_events/loki.rs | 10 +- src/internal_events/lua.rs | 8 +- src/internal_events/metric_to_log.rs | 6 +- src/internal_events/mongodb_metrics.rs | 10 +- src/internal_events/mqtt.rs | 4 +- src/internal_events/nginx_metrics.rs | 10 +- src/internal_events/open.rs | 6 +- src/internal_events/parser.rs | 8 +- src/internal_events/postgresql_metrics.rs | 4 +- src/internal_events/process.rs | 16 +-- src/internal_events/prometheus.rs | 8 +- src/internal_events/pulsar.rs | 14 +-- src/internal_events/redis.rs | 4 +- src/internal_events/reduce.rs | 6 +- src/internal_events/remap.rs | 7 +- src/internal_events/sematext_metrics.rs | 6 +- src/internal_events/socket.rs | 26 ++--- src/internal_events/splunk_hec.rs | 26 ++--- src/internal_events/statsd_sink.rs | 6 +- src/internal_events/tag_cardinality_limit.rs | 12 +- src/internal_events/tcp.rs | 14 +-- src/internal_events/template.rs | 4 +- src/internal_events/throttle.rs | 4 +- src/internal_events/udp.rs | 10 +- src/internal_events/unix.rs | 14 +-- src/internal_events/websocket.rs | 22 ++-- src/internal_events/websocket_server.rs | 18 +-- src/internal_telemetry/allocations/mod.rs | 10 +- src/topology/builder.rs | 8 +- 86 files changed, 569 insertions(+), 521 deletions(-) diff --git a/lib/codecs/src/internal_events.rs b/lib/codecs/src/internal_events.rs index 7547989140501..0518247e523a3 100644 --- a/lib/codecs/src/internal_events.rs +++ b/lib/codecs/src/internal_events.rs @@ -4,7 +4,7 @@ use tracing::error; use vector_common::{ counter, internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, emit, error_stage, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, emit, error_stage, error_type, }, }; @@ -27,7 +27,7 @@ impl InternalEvent for DecoderFramingError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "decoder_frame", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -53,7 +53,7 @@ impl InternalEvent for DecoderDeserializeError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "decoder_deserialize", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -80,7 +80,7 @@ impl InternalEvent for EncoderFramingError<'_> { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "encoder_frame", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -108,7 +108,7 @@ impl InternalEvent for EncoderSerializeError<'_> { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "encoder_serialize", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -140,7 +140,7 @@ impl InternalEvent for EncoderWriteError<'_, E> { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, ) @@ -173,7 +173,7 @@ impl InternalEvent for EncoderNullConstraintError<'_> { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "encoding_null_constraint", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -204,7 +204,7 @@ impl InternalEvent for EncoderRecordBatchError<'_, E> { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -231,7 +231,7 @@ impl InternalEvent for SchemaGenerationError<'_> { internal_log_rate_limit = false, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "parquet_schema_generation_failed", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -258,7 +258,7 @@ impl InternalEvent for ArrowWriterError<'_> { internal_log_rate_limit = false, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "parquet_arrow_writer_failed", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, @@ -284,7 +284,7 @@ impl InternalEvent for JsonSerializationError<'_> { internal_log_rate_limit = true, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::SENDING, ) diff --git a/lib/vector-buffers/src/internal_events.rs b/lib/vector-buffers/src/internal_events.rs index a165c540f9121..31a6089322d0c 100644 --- a/lib/vector-buffers/src/internal_events.rs +++ b/lib/vector-buffers/src/internal_events.rs @@ -4,7 +4,7 @@ use metrics::Histogram; use vector_common::NamedInternalEvent; use vector_common::{ counter, gauge, histogram, - internal_event::{InternalEvent, MetricName, error_type}, + internal_event::{CounterName, GaugeName, HistogramName, InternalEvent, error_type}, registered_event, }; @@ -22,14 +22,14 @@ impl InternalEvent for BufferCreated { let stage = self.idx.to_string(); if self.max_size_events != 0 { gauge!( - MetricName::BufferMaxSizeEvents, + GaugeName::BufferMaxSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => stage.clone(), ) .set(self.max_size_events as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferMaxEventSize, + GaugeName::BufferMaxEventSize, "buffer_id" => self.buffer_id.clone(), "stage" => stage.clone(), ) @@ -37,14 +37,14 @@ impl InternalEvent for BufferCreated { } if self.max_size_bytes != 0 { gauge!( - MetricName::BufferMaxSizeBytes, + GaugeName::BufferMaxSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => stage.clone(), ) .set(self.max_size_bytes as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferMaxByteSize, + GaugeName::BufferMaxByteSize, "buffer_id" => self.buffer_id, "stage" => stage, ) @@ -67,40 +67,40 @@ impl InternalEvent for BufferEventsReceived { #[expect(clippy::cast_precision_loss)] fn emit(self) { counter!( - MetricName::BufferReceivedEventsTotal, + CounterName::BufferReceivedEventsTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.count); counter!( - MetricName::BufferReceivedBytesTotal, + CounterName::BufferReceivedBytesTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.byte_size); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferEvents, + GaugeName::BufferEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - MetricName::BufferSizeEvents, + GaugeName::BufferSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - MetricName::BufferSizeBytes, + GaugeName::BufferSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_byte_size as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferByteSize, + GaugeName::BufferByteSize, "buffer_id" => self.buffer_id, "stage" => self.idx.to_string() ) @@ -122,39 +122,39 @@ impl InternalEvent for BufferEventsSent { #[expect(clippy::cast_precision_loss)] fn emit(self) { counter!( - MetricName::BufferSentEventsTotal, + CounterName::BufferSentEventsTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.count); counter!( - MetricName::BufferSentBytesTotal, + CounterName::BufferSentBytesTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .increment(self.byte_size); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferEvents, + GaugeName::BufferEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - MetricName::BufferSizeEvents, + GaugeName::BufferSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - MetricName::BufferSizeBytes, + GaugeName::BufferSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_byte_size as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferByteSize, + GaugeName::BufferByteSize, "buffer_id" => self.buffer_id, "stage" => self.idx.to_string() ) @@ -201,14 +201,14 @@ impl InternalEvent for BufferEventsDropped { } counter!( - MetricName::BufferDiscardedEventsTotal, + CounterName::BufferDiscardedEventsTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string(), "intentional" => intentional_str, ) .increment(self.count); counter!( - MetricName::BufferDiscardedBytesTotal, + CounterName::BufferDiscardedBytesTotal, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string(), "intentional" => intentional_str, @@ -216,26 +216,26 @@ impl InternalEvent for BufferEventsDropped { .increment(self.byte_size); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferEvents, + GaugeName::BufferEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - MetricName::BufferSizeEvents, + GaugeName::BufferSizeEvents, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_count as f64); gauge!( - MetricName::BufferSizeBytes, + GaugeName::BufferSizeBytes, "buffer_id" => self.buffer_id.clone(), "stage" => self.idx.to_string() ) .set(self.total_byte_size as f64); // DEPRECATED: buffer-bytes-events-metrics gauge!( - MetricName::BufferByteSize, + GaugeName::BufferByteSize, "buffer_id" => self.buffer_id, "stage" => self.idx.to_string() ) @@ -259,7 +259,7 @@ impl InternalEvent for BufferReadError { stage = "processing", ); counter!( - MetricName::BufferErrorsTotal, "error_code" => self.error_code, + CounterName::BufferErrorsTotal, "error_code" => self.error_code, "error_type" => "reader_failed", "stage" => "processing", ) @@ -271,7 +271,7 @@ registered_event! { BufferSendDuration { stage: usize, } => { - send_duration: Histogram = histogram!(MetricName::BufferSendDurationSeconds, "stage" => self.stage.to_string()), + send_duration: Histogram = histogram!(HistogramName::BufferSendDurationSeconds, "stage" => self.stage.to_string()), } fn emit(&self, duration: Duration) { diff --git a/lib/vector-common/src/internal_event/bytes_received.rs b/lib/vector-common/src/internal_event/bytes_received.rs index 47b016ed390bc..4264c3cbc365a 100644 --- a/lib/vector-common/src/internal_event/bytes_received.rs +++ b/lib/vector-common/src/internal_event/bytes_received.rs @@ -2,13 +2,13 @@ use metrics::Counter; use crate::counter; -use super::{ByteSize, MetricName, Protocol, SharedString}; +use super::{ByteSize, CounterName, Protocol, SharedString}; crate::registered_event!( BytesReceived { protocol: SharedString, } => { - received_bytes: Counter = counter!(MetricName::ComponentReceivedBytesTotal, "protocol" => self.protocol.clone()), + received_bytes: Counter = counter!(CounterName::ComponentReceivedBytesTotal, "protocol" => self.protocol.clone()), protocol: SharedString = self.protocol, } diff --git a/lib/vector-common/src/internal_event/bytes_sent.rs b/lib/vector-common/src/internal_event/bytes_sent.rs index b9a3f95dbcc06..b363893783f43 100644 --- a/lib/vector-common/src/internal_event/bytes_sent.rs +++ b/lib/vector-common/src/internal_event/bytes_sent.rs @@ -3,13 +3,13 @@ use metrics::Counter; use crate::counter; use tracing::trace; -use super::{ByteSize, MetricName, Protocol, SharedString}; +use super::{ByteSize, CounterName, Protocol, SharedString}; crate::registered_event!( BytesSent { protocol: SharedString, } => { - bytes_sent: Counter = counter!(MetricName::ComponentSentBytesTotal, "protocol" => self.protocol.clone()), + bytes_sent: Counter = counter!(CounterName::ComponentSentBytesTotal, "protocol" => self.protocol.clone()), protocol: SharedString = self.protocol, } diff --git a/lib/vector-common/src/internal_event/component_events_dropped.rs b/lib/vector-common/src/internal_event/component_events_dropped.rs index 258a9426deb0d..8421d1d0f49ae 100644 --- a/lib/vector-common/src/internal_event/component_events_dropped.rs +++ b/lib/vector-common/src/internal_event/component_events_dropped.rs @@ -2,7 +2,7 @@ use metrics::Counter; use crate::counter; -use super::{Count, InternalEvent, InternalEventHandle, MetricName, RegisterInternalEvent}; +use super::{Count, CounterName, InternalEvent, InternalEventHandle, RegisterInternalEvent}; use crate::NamedInternalEvent; pub const INTENTIONAL: bool = true; @@ -34,7 +34,7 @@ impl<'a, const INTENTIONAL: bool> RegisterInternalEvent fn register(self) -> Self::Handle { Self::Handle { discarded_events: counter!( - MetricName::ComponentDiscardedEventsTotal, + CounterName::ComponentDiscardedEventsTotal, "intentional" => if INTENTIONAL { "true" } else { "false" }, ), reason: self.reason, diff --git a/lib/vector-common/src/internal_event/component_events_timed_out.rs b/lib/vector-common/src/internal_event/component_events_timed_out.rs index 9fc0c90a399fd..4662322fe9776 100644 --- a/lib/vector-common/src/internal_event/component_events_timed_out.rs +++ b/lib/vector-common/src/internal_event/component_events_timed_out.rs @@ -2,14 +2,14 @@ use metrics::Counter; use crate::counter; -use super::{Count, MetricName}; +use super::{Count, CounterName}; crate::registered_event! { ComponentEventsTimedOut { reason: &'static str, } => { - timed_out_events: Counter = counter!(MetricName::ComponentTimedOutEventsTotal), - timed_out_requests: Counter = counter!(MetricName::ComponentTimedOutRequestsTotal), + timed_out_events: Counter = counter!(CounterName::ComponentTimedOutEventsTotal), + timed_out_requests: Counter = counter!(CounterName::ComponentTimedOutRequestsTotal), reason: &'static str = self.reason, } diff --git a/lib/vector-common/src/internal_event/events_received.rs b/lib/vector-common/src/internal_event/events_received.rs index d5ca521951d3d..a08ebc6e8438b 100644 --- a/lib/vector-common/src/internal_event/events_received.rs +++ b/lib/vector-common/src/internal_event/events_received.rs @@ -3,13 +3,13 @@ use metrics::{Counter, Histogram}; use crate::{counter, histogram}; use tracing::trace; -use super::{CountByteSize, MetricName}; +use super::{CountByteSize, CounterName, HistogramName}; crate::registered_event!( EventsReceived => { - events_count: Histogram = histogram!(MetricName::ComponentReceivedEventsCount), - events: Counter = counter!(MetricName::ComponentReceivedEventsTotal), - event_bytes: Counter = counter!(MetricName::ComponentReceivedEventBytesTotal), + events_count: Histogram = histogram!(HistogramName::ComponentReceivedEventsCount), + events: Counter = counter!(CounterName::ComponentReceivedEventsTotal), + event_bytes: Counter = counter!(CounterName::ComponentReceivedEventBytesTotal), } fn emit(&self, data: CountByteSize) { diff --git a/lib/vector-common/src/internal_event/events_sent.rs b/lib/vector-common/src/internal_event/events_sent.rs index 08d1b42d29a36..3ae63db761381 100644 --- a/lib/vector-common/src/internal_event/events_sent.rs +++ b/lib/vector-common/src/internal_event/events_sent.rs @@ -5,7 +5,7 @@ use metrics::Counter; use crate::counter; use tracing::trace; -use super::{CountByteSize, MetricName, OptionalTag, Output, SharedString}; +use super::{CountByteSize, CounterName, OptionalTag, Output, SharedString}; use crate::config::ComponentKey; pub const DEFAULT_OUTPUT: &str = "_default"; @@ -15,14 +15,14 @@ crate::registered_event!( output: Option, } => { events: Counter = if let Some(output) = &self.output { - counter!(MetricName::ComponentSentEventsTotal, "output" => output.clone()) + counter!(CounterName::ComponentSentEventsTotal, "output" => output.clone()) } else { - counter!(MetricName::ComponentSentEventsTotal) + counter!(CounterName::ComponentSentEventsTotal) }, event_bytes: Counter = if let Some(output) = &self.output { - counter!(MetricName::ComponentSentEventBytesTotal, "output" => output.clone()) + counter!(CounterName::ComponentSentEventBytesTotal, "output" => output.clone()) } else { - counter!(MetricName::ComponentSentEventBytesTotal) + counter!(CounterName::ComponentSentEventBytesTotal) }, output: Option = self.output, } @@ -77,10 +77,10 @@ crate::registered_event!( service: OptionalTag, } => { events: Counter = { - counter!(MetricName::ComponentSentEventsTotal, &make_tags(&self.source, &self.service)) + counter!(CounterName::ComponentSentEventsTotal, &make_tags(&self.source, &self.service)) }, event_bytes: Counter = { - counter!(MetricName::ComponentSentEventBytesTotal, &make_tags(&self.source, &self.service)) + counter!(CounterName::ComponentSentEventBytesTotal, &make_tags(&self.source, &self.service)) }, } diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs index 459667ec46005..c7e4d4f0d064c 100644 --- a/lib/vector-common/src/internal_event/metric_name.rs +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -3,10 +3,9 @@ use strum::{AsRefStr, Display, EnumIter}; /// Canonical list of all per-component internal metric names emitted by Vector. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display, AsRefStr, EnumIter)] #[strum(serialize_all = "snake_case")] -pub enum MetricName { +pub enum CounterName { ComponentReceivedEventsTotal, ComponentReceivedEventBytesTotal, - ComponentReceivedEventsCount, ComponentReceivedBytesTotal, ComponentSentEventsTotal, ComponentSentEventBytesTotal, @@ -15,10 +14,6 @@ pub enum MetricName { ComponentErrorsTotal, ComponentTimedOutEventsTotal, ComponentTimedOutRequestsTotal, - BufferMaxSizeEvents, - BufferMaxEventSize, - BufferMaxSizeBytes, - BufferMaxByteSize, BufferReceivedEventsTotal, BufferReceivedBytesTotal, BufferSentEventsTotal, @@ -26,16 +21,6 @@ pub enum MetricName { BufferDiscardedEventsTotal, BufferDiscardedBytesTotal, BufferErrorsTotal, - BufferSendDurationSeconds, - BufferEvents, - BufferSizeEvents, - BufferSizeBytes, - BufferByteSize, - ComponentLatencySeconds, - ComponentLatencyMeanSeconds, - SourceLagTimeSeconds, - SourceSendLatencySeconds, - SourceSendBatchLatencySeconds, // Internal events from src/internal_events/ ActiveClients, ActiveEndpoints, @@ -147,14 +132,69 @@ pub enum MetricName { MemoryEnrichmentTableTtlExpirations, } -impl MetricName { +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display, AsRefStr, EnumIter)] +#[strum(serialize_all = "snake_case")] +pub enum HistogramName { + ComponentReceivedEventsCount, + BufferSendDurationSeconds, + ComponentLatencySeconds, + SourceLagTimeSeconds, + SourceSendLatencySeconds, + SourceSendBatchLatencySeconds, +} + +impl HistogramName { + #[must_use] + pub const fn as_str(self) -> &'static str { + match self { + Self::ComponentReceivedEventsCount => "component_received_events_count", + Self::BufferSendDurationSeconds => "buffer_send_duration_seconds", + Self::ComponentLatencySeconds => "component_latency_seconds", + Self::SourceLagTimeSeconds => "source_lag_time_seconds", + Self::SourceSendLatencySeconds => "source_send_latency_seconds", + Self::SourceSendBatchLatencySeconds => "source_send_batch_latency_seconds", + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Display, AsRefStr, EnumIter)] +#[strum(serialize_all = "snake_case")] +pub enum GaugeName { + ComponentLatencyMeanSeconds, + BufferMaxSizeEvents, + BufferMaxEventSize, + BufferMaxSizeBytes, + BufferMaxByteSize, + BufferEvents, + BufferSizeEvents, + BufferSizeBytes, + BufferByteSize, +} + +impl GaugeName { + #[must_use] + pub const fn as_str(self) -> &'static str { + match self { + Self::ComponentLatencyMeanSeconds => "component_latency_mean_seconds", + Self::BufferMaxSizeEvents => "buffer_max_size_events", + Self::BufferMaxEventSize => "buffer_max_event_size", + Self::BufferMaxSizeBytes => "buffer_max_size_bytes", + Self::BufferMaxByteSize => "buffer_max_byte_size", + Self::BufferEvents => "buffer_events", + Self::BufferSizeEvents => "buffer_size_events", + Self::BufferSizeBytes => "buffer_size_bytes", + Self::BufferByteSize => "buffer_byte_size", + } + } +} + +impl CounterName { #[allow(clippy::too_many_lines)] #[must_use] pub const fn as_str(self) -> &'static str { match self { Self::ComponentReceivedEventsTotal => "component_received_events_total", Self::ComponentReceivedEventBytesTotal => "component_received_event_bytes_total", - Self::ComponentReceivedEventsCount => "component_received_events_count", Self::ComponentReceivedBytesTotal => "component_received_bytes_total", Self::ComponentSentEventsTotal => "component_sent_events_total", Self::ComponentSentEventBytesTotal => "component_sent_event_bytes_total", @@ -163,10 +203,6 @@ impl MetricName { Self::ComponentErrorsTotal => "component_errors_total", Self::ComponentTimedOutEventsTotal => "component_timed_out_events_total", Self::ComponentTimedOutRequestsTotal => "component_timed_out_requests_total", - Self::BufferMaxSizeEvents => "buffer_max_size_events", - Self::BufferMaxEventSize => "buffer_max_event_size", - Self::BufferMaxSizeBytes => "buffer_max_size_bytes", - Self::BufferMaxByteSize => "buffer_max_byte_size", Self::BufferReceivedEventsTotal => "buffer_received_events_total", Self::BufferReceivedBytesTotal => "buffer_received_bytes_total", Self::BufferSentEventsTotal => "buffer_sent_events_total", @@ -174,16 +210,6 @@ impl MetricName { Self::BufferDiscardedEventsTotal => "buffer_discarded_events_total", Self::BufferDiscardedBytesTotal => "buffer_discarded_bytes_total", Self::BufferErrorsTotal => "buffer_errors_total", - Self::BufferSendDurationSeconds => "buffer_send_duration_seconds", - Self::BufferEvents => "buffer_events", - Self::BufferSizeEvents => "buffer_size_events", - Self::BufferSizeBytes => "buffer_size_bytes", - Self::BufferByteSize => "buffer_byte_size", - Self::ComponentLatencySeconds => "component_latency_seconds", - Self::ComponentLatencyMeanSeconds => "component_latency_mean_seconds", - Self::SourceLagTimeSeconds => "source_lag_time_seconds", - Self::SourceSendLatencySeconds => "source_send_latency_seconds", - Self::SourceSendBatchLatencySeconds => "source_send_batch_latency_seconds", Self::ActiveClients => "active_clients", Self::ActiveEndpoints => "active_endpoints", Self::AdaptiveConcurrencyAveragedRtt => "adaptive_concurrency_averaged_rtt", @@ -277,22 +303,32 @@ impl MetricName { Self::WindowsServiceStartTotal => "windows_service_start_total", Self::WindowsServiceStopTotal => "windows_service_stop_total", Self::WindowsServiceUninstallTotal => "windows_service_uninstall_total", - Self::K8sEventNamespaceAnnotationFailuresTotal => "k8s_event_namespace_annotation_failures_total", + Self::K8sEventNamespaceAnnotationFailuresTotal => { + "k8s_event_namespace_annotation_failures_total" + } Self::K8sEventNodeAnnotationFailuresTotal => "k8s_event_node_annotation_failures_total", Self::K8sFormatPickerEdgeCasesTotal => "k8s_format_picker_edge_cases_total", Self::K8sDockerFormatParseFailuresTotal => "k8s_docker_format_parse_failures_total", - Self::S3ObjectProcessingSucceededDurationSeconds => "s3_object_processing_succeeded_duration_seconds", - Self::S3ObjectProcessingFailedDurationSeconds => "s3_object_processing_failed_duration_seconds", + Self::S3ObjectProcessingSucceededDurationSeconds => { + "s3_object_processing_succeeded_duration_seconds" + } + Self::S3ObjectProcessingFailedDurationSeconds => { + "s3_object_processing_failed_duration_seconds" + } Self::SqsS3EventRecordIgnoredTotal => "sqs_s3_event_record_ignored_total", Self::ComponentAllocatedBytesTotal => "component_allocated_bytes_total", Self::ComponentDeallocatedBytesTotal => "component_deallocated_bytes_total", Self::ComponentAllocatedBytes => "component_allocated_bytes", Self::Utilization => "utilization", Self::MemoryEnrichmentTableByteSize => "memory_enrichment_table_byte_size", - Self::MemoryEnrichmentTableFailedInsertions => "memory_enrichment_table_failed_insertions", + Self::MemoryEnrichmentTableFailedInsertions => { + "memory_enrichment_table_failed_insertions" + } Self::MemoryEnrichmentTableFailedReads => "memory_enrichment_table_failed_reads", Self::MemoryEnrichmentTableFlushesTotal => "memory_enrichment_table_flushes_total", - Self::MemoryEnrichmentTableInsertionsTotal => "memory_enrichment_table_insertions_total", + Self::MemoryEnrichmentTableInsertionsTotal => { + "memory_enrichment_table_insertions_total" + } Self::MemoryEnrichmentTableObjectsCount => "memory_enrichment_table_objects_count", Self::MemoryEnrichmentTableReadsTotal => "memory_enrichment_table_reads_total", Self::MemoryEnrichmentTableTtlExpirations => "memory_enrichment_table_ttl_expirations", diff --git a/lib/vector-common/src/internal_event/mod.rs b/lib/vector-common/src/internal_event/mod.rs index 0d1ace81fbbd1..e776e89553172 100644 --- a/lib/vector-common/src/internal_event/mod.rs +++ b/lib/vector-common/src/internal_event/mod.rs @@ -20,7 +20,7 @@ pub use component_events_dropped::{ComponentEventsDropped, INTENTIONAL, UNINTENT pub use component_events_timed_out::ComponentEventsTimedOut; pub use events_received::{EventsReceived, EventsReceivedHandle}; pub use events_sent::{DEFAULT_OUTPUT, EventsSent, TaggedEventsSent}; -pub use metric_name::MetricName; +pub use metric_name::{CounterName, GaugeName, HistogramName}; pub use metrics::SharedString; pub use optional_tag::OptionalTag; pub use prelude::{error_stage, error_type}; diff --git a/lib/vector-common/src/internal_event/service.rs b/lib/vector-common/src/internal_event/service.rs index 536899c2f356f..60d615b3d61a0 100644 --- a/lib/vector-common/src/internal_event/service.rs +++ b/lib/vector-common/src/internal_event/service.rs @@ -1,4 +1,4 @@ -use super::MetricName; +use super::CounterName; use crate::counter; @@ -19,7 +19,7 @@ impl InternalEvent for PollReadyError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::SENDING, ) @@ -45,7 +45,7 @@ impl InternalEvent for CallError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::SENDING, ) diff --git a/lib/vector-common/src/lib.rs b/lib/vector-common/src/lib.rs index b577eb2bcc463..54617fbc5bdb2 100644 --- a/lib/vector-common/src/lib.rs +++ b/lib/vector-common/src/lib.rs @@ -74,14 +74,14 @@ extern crate tracing; #[macro_export] macro_rules! counter { ($name:expr) => {{ - let _name: $crate::internal_event::MetricName = $name; + let _name: $crate::internal_event::CounterName = $name; #[allow(clippy::disallowed_macros)] { metrics::counter!(_name.as_str()) } }}; ($name:expr, $($rest:tt)*) => {{ - let _name: $crate::internal_event::MetricName = $name; + let _name: $crate::internal_event::CounterName = $name; #[allow(clippy::disallowed_macros)] { metrics::counter!(_name.as_str(), $($rest)*) @@ -93,14 +93,14 @@ macro_rules! counter { #[macro_export] macro_rules! histogram { ($name:expr) => {{ - let _name: $crate::internal_event::MetricName = $name; + let _name: $crate::internal_event::HistogramName = $name; #[allow(clippy::disallowed_macros)] { metrics::histogram!(_name.as_str()) } }}; ($name:expr, $($rest:tt)*) => {{ - let _name: $crate::internal_event::MetricName = $name; + let _name: $crate::internal_event::HistogramName = $name; #[allow(clippy::disallowed_macros)] { metrics::histogram!(_name.as_str(), $($rest)*) @@ -112,14 +112,14 @@ macro_rules! histogram { #[macro_export] macro_rules! gauge { ($name:expr) => {{ - let _name: $crate::internal_event::MetricName = $name; + let _name: $crate::internal_event::GaugeName = $name; #[allow(clippy::disallowed_macros)] { metrics::gauge!(_name.as_str()) } }}; ($name:expr, $($rest:tt)*) => {{ - let _name: $crate::internal_event::MetricName = $name; + let _name: $crate::internal_event::GaugeName = $name; #[allow(clippy::disallowed_macros)] { metrics::gauge!(_name.as_str(), $($rest)*) diff --git a/lib/vector-core/src/latency.rs b/lib/vector-core/src/latency.rs index 3dd9da20da65d..61d51d3a44a81 100644 --- a/lib/vector-core/src/latency.rs +++ b/lib/vector-core/src/latency.rs @@ -2,7 +2,7 @@ use std::time::Instant; use metrics::Histogram; use vector_common::stats::EwmaGauge; -use vector_common::{gauge, histogram, internal_event::MetricName}; +use vector_common::{gauge, histogram, internal_event::{GaugeName, HistogramName}}; use crate::event::EventArray; @@ -17,9 +17,9 @@ pub struct LatencyRecorder { impl LatencyRecorder { pub fn new(ewma_alpha: Option) -> Self { Self { - histogram: histogram!(MetricName::ComponentLatencySeconds), + histogram: histogram!(HistogramName::ComponentLatencySeconds), gauge: EwmaGauge::new( - gauge!(MetricName::ComponentLatencyMeanSeconds), + gauge!(GaugeName::ComponentLatencyMeanSeconds), ewma_alpha.or(Some(DEFAULT_LATENCY_EWMA_ALPHA)), ), } diff --git a/lib/vector-core/src/source_sender/mod.rs b/lib/vector-core/src/source_sender/mod.rs index c60cc0be4f8c3..24eb23688c0a1 100644 --- a/lib/vector-core/src/source_sender/mod.rs +++ b/lib/vector-core/src/source_sender/mod.rs @@ -22,8 +22,8 @@ pub const CHUNK_SIZE: usize = 1000; #[cfg(any(test, feature = "test"))] const TEST_BUFFER_SIZE: usize = 100; -use vector_common::internal_event::MetricName; +use vector_common::internal_event::HistogramName; -const LAG_TIME_NAME: MetricName = MetricName::SourceLagTimeSeconds; -const SEND_LATENCY_NAME: MetricName = MetricName::SourceSendLatencySeconds; -const SEND_BATCH_LATENCY_NAME: MetricName = MetricName::SourceSendBatchLatencySeconds; +const LAG_TIME_NAME: HistogramName = HistogramName::SourceLagTimeSeconds; +const SEND_LATENCY_NAME: HistogramName = HistogramName::SourceSendLatencySeconds; +const SEND_BATCH_LATENCY_NAME: HistogramName = HistogramName::SourceSendBatchLatencySeconds; diff --git a/src/enrichment_tables/memory/internal_events.rs b/src/enrichment_tables/memory/internal_events.rs index becbfd4146bb1..b6553443fbc48 100644 --- a/src/enrichment_tables/memory/internal_events.rs +++ b/src/enrichment_tables/memory/internal_events.rs @@ -1,7 +1,8 @@ use vector_lib::{ - NamedInternalEvent, configurable::configurable_component, + NamedInternalEvent, + configurable::configurable_component, counter, gauge, - internal_event::{InternalEvent, MetricName}, + internal_event::{CounterName, InternalEvent}, }; /// Configuration of internal metrics for enrichment memory table. @@ -27,12 +28,12 @@ impl InternalEvent for MemoryEnrichmentTableRead<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - MetricName::MemoryEnrichmentTableReadsTotal, + CounterName::MemoryEnrichmentTableReadsTotal, "key" => self.key.to_owned() ) .increment(1); } else { - counter!(MetricName::MemoryEnrichmentTableReadsTotal,).increment(1); + counter!(CounterName::MemoryEnrichmentTableReadsTotal,).increment(1); } } } @@ -47,12 +48,12 @@ impl InternalEvent for MemoryEnrichmentTableInserted<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - MetricName::MemoryEnrichmentTableInsertionsTotal, + CounterName::MemoryEnrichmentTableInsertionsTotal, "key" => self.key.to_owned() ) .increment(1); } else { - counter!(MetricName::MemoryEnrichmentTableInsertionsTotal,).increment(1); + counter!(CounterName::MemoryEnrichmentTableInsertionsTotal,).increment(1); } } } @@ -65,9 +66,9 @@ pub(crate) struct MemoryEnrichmentTableFlushed { impl InternalEvent for MemoryEnrichmentTableFlushed { fn emit(self) { - counter!(MetricName::MemoryEnrichmentTableFlushesTotal,).increment(1); - gauge!(MetricName::MemoryEnrichmentTableObjectsCount,).set(self.new_objects_count as f64); - gauge!(MetricName::MemoryEnrichmentTableByteSize,).set(self.new_byte_size as f64); + counter!(CounterName::MemoryEnrichmentTableFlushesTotal,).increment(1); + gauge!(CounterName::MemoryEnrichmentTableObjectsCount,).set(self.new_objects_count as f64); + gauge!(CounterName::MemoryEnrichmentTableByteSize,).set(self.new_byte_size as f64); } } @@ -81,12 +82,12 @@ impl InternalEvent for MemoryEnrichmentTableTtlExpired<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - MetricName::MemoryEnrichmentTableTtlExpirations, + CounterName::MemoryEnrichmentTableTtlExpirations, "key" => self.key.to_owned() ) .increment(1); } else { - counter!(MetricName::MemoryEnrichmentTableTtlExpirations,).increment(1); + counter!(CounterName::MemoryEnrichmentTableTtlExpirations,).increment(1); } } } @@ -101,12 +102,12 @@ impl InternalEvent for MemoryEnrichmentTableReadFailed<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - MetricName::MemoryEnrichmentTableFailedReads, + CounterName::MemoryEnrichmentTableFailedReads, "key" => self.key.to_owned() ) .increment(1); } else { - counter!(MetricName::MemoryEnrichmentTableFailedReads,).increment(1); + counter!(CounterName::MemoryEnrichmentTableFailedReads,).increment(1); } } } @@ -121,12 +122,12 @@ impl InternalEvent for MemoryEnrichmentTableInsertFailed<'_> { fn emit(self) { if self.include_key_metric_tag { counter!( - MetricName::MemoryEnrichmentTableFailedInsertions, + CounterName::MemoryEnrichmentTableFailedInsertions, "key" => self.key.to_owned() ) .increment(1); } else { - counter!(MetricName::MemoryEnrichmentTableFailedInsertions,).increment(1); + counter!(CounterName::MemoryEnrichmentTableFailedInsertions,).increment(1); } } } diff --git a/src/internal_events/adaptive_concurrency.rs b/src/internal_events/adaptive_concurrency.rs index 0d6b09026f962..c60bbb678072c 100644 --- a/src/internal_events/adaptive_concurrency.rs +++ b/src/internal_events/adaptive_concurrency.rs @@ -2,7 +2,7 @@ use std::time::Duration; use metrics::Histogram; use vector_lib::histogram; -use vector_lib::internal_event::MetricName; +use vector_lib::internal_event::CounterName; #[derive(Clone, Copy)] pub struct AdaptiveConcurrencyLimitData { @@ -19,10 +19,10 @@ registered_event! { // These are histograms, as they may have a number of different // values over each reporting interval, and each of those values // is valuable for diagnosis. - limit: Histogram = histogram!(MetricName::AdaptiveConcurrencyLimit), - reached_limit: Histogram = histogram!(MetricName::AdaptiveConcurrencyReachedLimit), - back_pressure: Histogram = histogram!(MetricName::AdaptiveConcurrencyBackPressure), - past_rtt_mean: Histogram = histogram!(MetricName::AdaptiveConcurrencyPastRttMean), + limit: Histogram = histogram!(CounterName::AdaptiveConcurrencyLimit), + reached_limit: Histogram = histogram!(CounterName::AdaptiveConcurrencyReachedLimit), + back_pressure: Histogram = histogram!(CounterName::AdaptiveConcurrencyBackPressure), + past_rtt_mean: Histogram = histogram!(CounterName::AdaptiveConcurrencyPastRttMean), } fn emit(&self, data: AdaptiveConcurrencyLimitData) { @@ -38,7 +38,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyInFlight => { - in_flight: Histogram = histogram!(MetricName::AdaptiveConcurrencyInFlight), + in_flight: Histogram = histogram!(CounterName::AdaptiveConcurrencyInFlight), } fn emit(&self, in_flight: u64) { @@ -48,7 +48,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyObservedRtt => { - observed_rtt: Histogram = histogram!(MetricName::AdaptiveConcurrencyObservedRtt), + observed_rtt: Histogram = histogram!(CounterName::AdaptiveConcurrencyObservedRtt), } fn emit(&self, rtt: Duration) { @@ -58,7 +58,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyAveragedRtt => { - averaged_rtt: Histogram = histogram!(MetricName::AdaptiveConcurrencyAveragedRtt), + averaged_rtt: Histogram = histogram!(CounterName::AdaptiveConcurrencyAveragedRtt), } fn emit(&self, rtt: Duration) { diff --git a/src/internal_events/aggregate.rs b/src/internal_events/aggregate.rs index aee7d0bc6bdac..b47aee35f0546 100644 --- a/src/internal_events/aggregate.rs +++ b/src/internal_events/aggregate.rs @@ -1,12 +1,12 @@ +use vector_lib::internal_event::{CounterName, InternalEvent}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct AggregateEventRecorded; impl InternalEvent for AggregateEventRecorded { fn emit(self) { - counter!(MetricName::AggregateEventsRecordedTotal).increment(1); + counter!(CounterName::AggregateEventsRecordedTotal).increment(1); } } @@ -15,7 +15,7 @@ pub struct AggregateFlushed; impl InternalEvent for AggregateFlushed { fn emit(self) { - counter!(MetricName::AggregateFlushesTotal).increment(1); + counter!(CounterName::AggregateFlushesTotal).increment(1); } } @@ -24,6 +24,6 @@ pub struct AggregateUpdateFailed; impl InternalEvent for AggregateUpdateFailed { fn emit(self) { - counter!(MetricName::AggregateFailedUpdates).increment(1); + counter!(CounterName::AggregateFailedUpdates).increment(1); } } diff --git a/src/internal_events/amqp.rs b/src/internal_events/amqp.rs index d6294c5ad8ade..54d7251026f5b 100644 --- a/src/internal_events/amqp.rs +++ b/src/internal_events/amqp.rs @@ -1,7 +1,7 @@ #[cfg(feature = "sources-amqp")] pub mod source { + use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; - use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct AmqpBytesReceived { @@ -17,7 +17,7 @@ pub mod source { protocol = %self.protocol, ); counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "protocol" => self.protocol, ) .increment(self.byte_size as u64); @@ -37,7 +37,7 @@ pub mod source { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) @@ -58,7 +58,7 @@ pub mod source { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::RECEIVING, ) @@ -79,7 +79,7 @@ pub mod source { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/apache_metrics.rs b/src/internal_events/apache_metrics.rs index 54ead6e4ae057..24d82925c0ec0 100644 --- a/src/internal_events/apache_metrics.rs +++ b/src/internal_events/apache_metrics.rs @@ -1,7 +1,7 @@ use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; @@ -19,12 +19,12 @@ impl InternalEvent for ApacheMetricsEventsReceived<'_> { fn emit(self) { trace!(message = "Events received.", count = %self.count, byte_size = %self.byte_size, endpoint = %self.endpoint); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -47,7 +47,7 @@ impl InternalEvent for ApacheMetricsParseError<'_> { endpoint = %self.endpoint, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, "endpoint" => self.endpoint.to_owned(), diff --git a/src/internal_events/api.rs b/src/internal_events/api.rs index bae96b9d34281..10b349ddc50d8 100644 --- a/src/internal_events/api.rs +++ b/src/internal_events/api.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; +use vector_lib::internal_event::{CounterName, InternalEvent}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct ApiStarted { @@ -14,6 +14,6 @@ impl InternalEvent for ApiStarted { message = "API server running.", address = %self.addr, ); - counter!(MetricName::ApiStartedTotal).increment(1); + counter!(CounterName::ApiStartedTotal).increment(1); } } diff --git a/src/internal_events/aws.rs b/src/internal_events/aws.rs index 5d29fb584fe80..67c931f088510 100644 --- a/src/internal_events/aws.rs +++ b/src/internal_events/aws.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(NamedInternalEvent)] pub struct AwsBytesSent { @@ -20,7 +20,7 @@ impl InternalEvent for AwsBytesSent { region = ?self.region, ); counter!( - MetricName::ComponentSentBytesTotal, + CounterName::ComponentSentBytesTotal, "protocol" => "https", "region" => region, ) diff --git a/src/internal_events/aws_cloudwatch_logs.rs b/src/internal_events/aws_cloudwatch_logs.rs index f206c896505c0..b4964f25d84fe 100644 --- a/src/internal_events/aws_cloudwatch_logs.rs +++ b/src/internal_events/aws_cloudwatch_logs.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct AwsCloudwatchLogsMessageSizeError { @@ -21,7 +21,7 @@ impl InternalEvent for AwsCloudwatchLogsMessageSizeError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "message_too_long", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/aws_ec2_metadata.rs b/src/internal_events/aws_ec2_metadata.rs index 92a76a95d46b6..296e4fd7d7dc4 100644 --- a/src/internal_events/aws_ec2_metadata.rs +++ b/src/internal_events/aws_ec2_metadata.rs @@ -1,5 +1,5 @@ use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct AwsEc2MetadataRefreshSuccessful; @@ -7,7 +7,7 @@ pub struct AwsEc2MetadataRefreshSuccessful; impl InternalEvent for AwsEc2MetadataRefreshSuccessful { fn emit(self) { debug!(message = "AWS EC2 metadata refreshed."); - counter!(MetricName::MetadataRefreshSuccessfulTotal).increment(1); + counter!(CounterName::MetadataRefreshSuccessfulTotal).increment(1); } } @@ -25,12 +25,12 @@ impl InternalEvent for AwsEc2MetadataRefreshError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::PROCESSING, ) .increment(1); // deprecated - counter!(MetricName::MetadataRefreshFailedTotal).increment(1); + counter!(CounterName::MetadataRefreshFailedTotal).increment(1); } } diff --git a/src/internal_events/aws_ecs_metrics.rs b/src/internal_events/aws_ecs_metrics.rs index 45028dc3b6b8f..dcb774d439504 100644 --- a/src/internal_events/aws_ecs_metrics.rs +++ b/src/internal_events/aws_ecs_metrics.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; @@ -24,12 +24,12 @@ impl InternalEvent for AwsEcsMetricsEventsReceived<'_> { endpoint = %self.endpoint, ); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_string(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_string(), ) .increment(self.byte_size.get() as u64); @@ -57,9 +57,9 @@ impl InternalEvent for AwsEcsMetricsParseError<'_> { endpoint = %self.endpoint, "Failed to parse response.", ); - counter!(MetricName::ParseErrorsTotal).increment(1); + counter!(CounterName::ParseErrorsTotal).increment(1); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, "endpoint" => self.endpoint.to_string(), diff --git a/src/internal_events/aws_kinesis.rs b/src/internal_events/aws_kinesis.rs index 79ff749b51ccf..f8a7dcff49de2 100644 --- a/src/internal_events/aws_kinesis.rs +++ b/src/internal_events/aws_kinesis.rs @@ -2,7 +2,7 @@ use vector_lib::NamedInternalEvent; /// Used in both `aws_kinesis_streams` and `aws_kinesis_firehose` sinks use vector_lib::counter; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] @@ -22,7 +22,7 @@ impl InternalEvent for AwsKinesisStreamNoPartitionKeyError<'_> { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/aws_kinesis_firehose.rs b/src/internal_events/aws_kinesis_firehose.rs index 05ddd66b4dee1..ed7b12e37f67a 100644 --- a/src/internal_events/aws_kinesis_firehose.rs +++ b/src/internal_events/aws_kinesis_firehose.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use super::prelude::{http_error_code, io_error_code}; use crate::sources::aws_kinesis_firehose::Compression; @@ -48,7 +48,7 @@ impl InternalEvent for AwsKinesisFirehoseRequestError<'_> { request_id = %self.request_id.unwrap_or(""), ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::REQUEST_FAILED, "error_code" => self.error_code, @@ -74,7 +74,7 @@ impl InternalEvent for AwsKinesisFirehoseAutomaticRecordDecodeError { compression = %self.compression, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, "error_code" => io_error_code(&self.error), diff --git a/src/internal_events/aws_sqs.rs b/src/internal_events/aws_sqs.rs index 94f42eff52530..b828072f287cf 100644 --- a/src/internal_events/aws_sqs.rs +++ b/src/internal_events/aws_sqs.rs @@ -4,7 +4,7 @@ pub use s3::*; use vector_lib::counter; #[cfg(any(feature = "sources-aws_s3", feature = "sources-aws_sqs"))] -use vector_lib::internal_event::{MetricName, error_stage, error_type}; +use vector_lib::internal_event::{CounterName, error_stage, error_type}; use vector_lib::{NamedInternalEvent, internal_event::InternalEvent}; #[cfg(feature = "sources-aws_s3")] @@ -34,7 +34,7 @@ mod s3 { duration_ms = %self.duration.as_millis(), ); histogram!( - MetricName::S3ObjectProcessingSucceededDurationSeconds, + CounterName::S3ObjectProcessingSucceededDurationSeconds, "bucket" => self.bucket.to_owned(), ) .record(self.duration); @@ -55,7 +55,7 @@ mod s3 { duration_ms = %self.duration.as_millis(), ); histogram!( - MetricName::S3ObjectProcessingFailedDurationSeconds, + CounterName::S3ObjectProcessingFailedDurationSeconds, "bucket" => self.bucket.to_owned(), ) .record(self.duration); @@ -79,7 +79,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_processing_sqs_message", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -100,7 +100,7 @@ mod s3 { .map(|x| x.id.as_str()) .collect::>() .join(", ")); - counter!(MetricName::SqsMessageDeleteSucceededTotal) + counter!(CounterName::SqsMessageDeleteSucceededTotal) .increment(self.message_ids.len() as u64); } } @@ -123,7 +123,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_deleting_some_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -152,7 +152,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_deleting_all_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -173,7 +173,7 @@ mod s3 { .map(|x| x.id.as_str()) .collect::>() .join(", ")); - counter!(MetricName::SqsMessageDeferSucceededTotal) + counter!(CounterName::SqsMessageDeferSucceededTotal) .increment(self.message_ids.len() as u64); } } @@ -196,7 +196,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_deferring_some_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -225,7 +225,7 @@ mod s3 { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_deferring_all_sqs_messages", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::PROCESSING, @@ -250,7 +250,7 @@ impl InternalEvent for SqsMessageReceiveError<'_, E> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_fetching_sqs_events", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -267,8 +267,8 @@ pub struct SqsMessageReceiveSucceeded { impl InternalEvent for SqsMessageReceiveSucceeded { fn emit(self) { trace!(message = "Received SQS messages.", count = %self.count); - counter!(MetricName::SqsMessageReceiveSucceededTotal).increment(1); - counter!(MetricName::SqsMessageReceivedMessagesTotal).increment(self.count as u64); + counter!(CounterName::SqsMessageReceiveSucceededTotal).increment(1); + counter!(CounterName::SqsMessageReceivedMessagesTotal).increment(self.count as u64); } } @@ -280,7 +280,7 @@ pub struct SqsMessageProcessingSucceeded<'a> { impl InternalEvent for SqsMessageProcessingSucceeded<'_> { fn emit(self) { trace!(message = "Processed SQS message successfully.", message_id = %self.message_id); - counter!(MetricName::SqsMessageProcessingSucceededTotal).increment(1); + counter!(CounterName::SqsMessageProcessingSucceededTotal).increment(1); } } @@ -302,7 +302,7 @@ impl InternalEvent for SqsMessageDeleteError<'_, E> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::PROCESSING, ) @@ -324,7 +324,7 @@ impl InternalEvent for SqsS3EventRecordInvalidEventIgnored<'_> { fn emit(self) { warn!(message = "Ignored S3 record in SQS message for an event that was not ObjectCreated.", bucket = %self.bucket, key = %self.key, kind = %self.kind, name = %self.name); - counter!(MetricName::SqsS3EventRecordIgnoredTotal, "ignore_type" => "invalid_event_kind") + counter!(CounterName::SqsS3EventRecordIgnoredTotal, "ignore_type" => "invalid_event_kind") .increment(1); } } diff --git a/src/internal_events/batch.rs b/src/internal_events/batch.rs index 4f1fba482f842..bd553c1e9863d 100644 --- a/src/internal_events/batch.rs +++ b/src/internal_events/batch.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct LargeEventDroppedError { @@ -20,7 +20,7 @@ impl InternalEvent for LargeEventDroppedError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "oversized", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::SENDING, diff --git a/src/internal_events/common.rs b/src/internal_events/common.rs index 3a7eef089f230..94095a7de24ea 100644 --- a/src/internal_events/common.rs +++ b/src/internal_events/common.rs @@ -3,7 +3,7 @@ use std::time::Instant; use vector_lib::NamedInternalEvent; pub use vector_lib::internal_event::EventsReceived; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use vector_lib::{counter, histogram}; @@ -23,7 +23,7 @@ impl InternalEvent for EndpointBytesReceived<'_> { endpoint = %self.endpoint, ); counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "protocol" => self.protocol.to_owned(), "endpoint" => self.endpoint.to_owned(), ) @@ -47,7 +47,7 @@ impl InternalEvent for EndpointBytesSent<'_> { endpoint = %self.endpoint ); counter!( - MetricName::ComponentSentBytesTotal, + CounterName::ComponentSentBytesTotal, "protocol" => self.protocol.to_string(), "endpoint" => self.endpoint.to_string() ) @@ -70,7 +70,7 @@ impl InternalEvent for SocketOutgoingConnectionError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_connecting", "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::SENDING, @@ -95,7 +95,7 @@ impl InternalEvent for StreamClosedError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => STREAM_CLOSED, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -117,8 +117,8 @@ pub struct CollectionCompleted { impl InternalEvent for CollectionCompleted { fn emit(self) { debug!(message = "Collection completed."); - counter!(MetricName::CollectCompletedTotal).increment(1); - histogram!(MetricName::CollectDurationSeconds).record(self.end - self.start); + counter!(CounterName::CollectCompletedTotal).increment(1); + histogram!(CounterName::CollectDurationSeconds).record(self.end - self.start); } } @@ -139,7 +139,7 @@ impl InternalEvent for SinkRequestBuildError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/conditions.rs b/src/internal_events/conditions.rs index fc1abbc3f0e47..80985af88e45b 100644 --- a/src/internal_events/conditions.rs +++ b/src/internal_events/conditions.rs @@ -1,5 +1,5 @@ use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; #[derive(Debug, Copy, Clone, NamedInternalEvent)] pub struct VrlConditionExecutionError<'a> { @@ -15,7 +15,7 @@ impl InternalEvent for VrlConditionExecutionError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::SCRIPT_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/datadog_agent.rs b/src/internal_events/datadog_agent.rs index 6f6e8038dc60b..c1e6dff0d53c2 100644 --- a/src/internal_events/datadog_agent.rs +++ b/src/internal_events/datadog_agent.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct DatadogAgentJsonParseError<'a> { @@ -15,7 +15,7 @@ impl InternalEvent for DatadogAgentJsonParseError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/datadog_metrics.rs b/src/internal_events/datadog_metrics.rs index 69414003404dc..00e7d50a8a7d7 100644 --- a/src/internal_events/datadog_metrics.rs +++ b/src/internal_events/datadog_metrics.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct DatadogMetricsEncodingError<'a> { @@ -20,7 +20,7 @@ impl InternalEvent for DatadogMetricsEncodingError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/datadog_traces.rs b/src/internal_events/datadog_traces.rs index fdd48ad427d95..016002681f81b 100644 --- a/src/internal_events/datadog_traces.rs +++ b/src/internal_events/datadog_traces.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct DatadogTracesEncodingError { @@ -21,7 +21,7 @@ impl InternalEvent for DatadogTracesEncodingError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) @@ -50,7 +50,7 @@ impl InternalEvent for DatadogTracesAPMStatsError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) diff --git a/src/internal_events/dnstap.rs b/src/internal_events/dnstap.rs index 7dd21fc5a1ca5..4a6ce045e88ab 100644 --- a/src/internal_events/dnstap.rs +++ b/src/internal_events/dnstap.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub(crate) struct DnstapParseError { @@ -15,7 +15,7 @@ impl InternalEvent for DnstapParseError { error_type = error_type::PARSER_FAILED, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, ) diff --git a/src/internal_events/docker_logs.rs b/src/internal_events/docker_logs.rs index ae7809aebc0c0..7e21ad9b59ba0 100644 --- a/src/internal_events/docker_logs.rs +++ b/src/internal_events/docker_logs.rs @@ -3,7 +3,7 @@ use chrono::ParseError; use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{InternalEvent, CounterName, error_stage, error_type}, json_size::JsonSize, }; @@ -23,11 +23,11 @@ impl InternalEvent for DockerLogsEventsReceived<'_> { container_id = %self.container_id ); counter!( - MetricName::ComponentReceivedEventsTotal, "container_name" => self.container_name.to_owned() + CounterName::ComponentReceivedEventsTotal, "container_name" => self.container_name.to_owned() ) .increment(1); counter!( - MetricName::ComponentReceivedEventBytesTotal, "container_name" => self.container_name.to_owned() + CounterName::ComponentReceivedEventBytesTotal, "container_name" => self.container_name.to_owned() ).increment(self.byte_size.get() as u64); } } @@ -45,7 +45,7 @@ impl InternalEvent for DockerLogsContainerEventReceived<'_> { container_id = %self.container_id, action = %self.action, ); - counter!(MetricName::ContainerProcessedEventsTotal).increment(1); + counter!(CounterName::ContainerProcessedEventsTotal).increment(1); } } @@ -60,7 +60,7 @@ impl InternalEvent for DockerLogsContainerWatch<'_> { message = "Started watching for container logs.", container_id = %self.container_id, ); - counter!(MetricName::ContainersWatchedTotal).increment(1); + counter!(CounterName::ContainersWatchedTotal).increment(1); } } @@ -75,7 +75,7 @@ impl InternalEvent for DockerLogsContainerUnwatch<'_> { message = "Stopped watching for container logs.", container_id = %self.container_id, ); - counter!(MetricName::ContainersUnwatchedTotal).increment(1); + counter!(CounterName::ContainersUnwatchedTotal).increment(1); } } @@ -95,7 +95,7 @@ impl InternalEvent for DockerLogsCommunicationError<'_> { container_id = ?self.container_id ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, ) @@ -119,7 +119,7 @@ impl InternalEvent for DockerLogsContainerMetadataFetchError<'_> { container_id = ?self.container_id ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, "container_id" => self.container_id.to_owned(), @@ -144,7 +144,7 @@ impl InternalEvent for DockerLogsTimestampParseError<'_> { container_id = ?self.container_id ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, "container_id" => self.container_id.to_owned(), @@ -169,7 +169,7 @@ impl InternalEvent for DockerLogsLoggingDriverUnsupportedError<'_> { container_id = ?self.container_id, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::RECEIVING, "container_id" => self.container_id.to_owned(), diff --git a/src/internal_events/doris.rs b/src/internal_events/doris.rs index 7ebff3540e89e..15dffd26418b4 100644 --- a/src/internal_events/doris.rs +++ b/src/internal_events/doris.rs @@ -1,4 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter, internal_event::{InternalEvent, MetricName}}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent}, +}; /// Emitted when rows are successfully loaded into Doris. #[derive(Debug, NamedInternalEvent)] @@ -16,10 +19,10 @@ impl InternalEvent for DorisRowsLoaded { ); // Record the number of rows loaded - counter!(MetricName::DorisRowsLoadedTotal).increment(self.loaded_rows as u64); + counter!(CounterName::DorisRowsLoadedTotal).increment(self.loaded_rows as u64); // Record the number of bytes loaded - counter!(MetricName::DorisBytesLoadedTotal).increment(self.load_bytes as u64); + counter!(CounterName::DorisBytesLoadedTotal).increment(self.load_bytes as u64); } } @@ -36,6 +39,6 @@ impl InternalEvent for DorisRowsFiltered { filtered_rows = %self.filtered_rows ); - counter!(MetricName::DorisRowsFilteredTotal).increment(self.filtered_rows as u64); + counter!(CounterName::DorisRowsFilteredTotal).increment(self.filtered_rows as u64); } } diff --git a/src/internal_events/encoding_transcode.rs b/src/internal_events/encoding_transcode.rs index d1fc3ebe1f91d..85f0ac7cf8130 100644 --- a/src/internal_events/encoding_transcode.rs +++ b/src/internal_events/encoding_transcode.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct DecoderBomRemoval { @@ -12,7 +12,7 @@ impl InternalEvent for DecoderBomRemoval { message = "Removing initial BOM bytes from the final output while decoding to utf8.", from_encoding = %self.from_encoding ); - counter!(MetricName::DecoderBomRemovalsTotal).increment(1); + counter!(CounterName::DecoderBomRemovalsTotal).increment(1); } } @@ -29,7 +29,7 @@ impl InternalEvent for DecoderMalformedReplacement { ); // NOT the actual number of replacements in the output: there's no easy // way to get that from the lib we use here (encoding_rs) - counter!(MetricName::DecoderMalformedReplacementWarningsTotal).increment(1); + counter!(CounterName::DecoderMalformedReplacementWarningsTotal).increment(1); } } @@ -46,6 +46,6 @@ impl InternalEvent for EncoderUnmappableReplacement { ); // NOT the actual number of replacements in the output: there's no easy // way to get that from the lib we use here (encoding_rs) - counter!(MetricName::EncoderUnmappableReplacementWarningsTotal).increment(1); + counter!(CounterName::EncoderUnmappableReplacementWarningsTotal).increment(1); } } diff --git a/src/internal_events/eventstoredb_metrics.rs b/src/internal_events/eventstoredb_metrics.rs index 650282793d279..13ff76336a864 100644 --- a/src/internal_events/eventstoredb_metrics.rs +++ b/src/internal_events/eventstoredb_metrics.rs @@ -1,5 +1,5 @@ use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct EventStoreDbMetricsHttpError { @@ -15,7 +15,7 @@ impl InternalEvent for EventStoreDbMetricsHttpError { error_type = error_type::REQUEST_FAILED, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::REQUEST_FAILED, ) @@ -37,7 +37,7 @@ impl InternalEvent for EventStoreDbStatsParsingError { error_type = error_type::PARSER_FAILED, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, ) diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index fd573031b7f4e..bbe5493f216fb 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -4,7 +4,7 @@ use tokio::time::error::Elapsed; use vector_lib::{ NamedInternalEvent, internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; @@ -28,12 +28,12 @@ impl InternalEvent for ExecEventsReceived<'_> { command = %self.command, ); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "command" => self.command.to_owned(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "command" => self.command.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -57,7 +57,7 @@ impl InternalEvent for ExecFailedError<'_> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "command" => self.command.to_owned(), "error_type" => error_type::COMMAND_FAILED, "error_code" => io_error_code(&self.error), @@ -85,7 +85,7 @@ impl InternalEvent for ExecTimeoutError<'_> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "command" => self.command.to_owned(), "error_type" => error_type::TIMED_OUT, "stage" => error_stage::RECEIVING, @@ -120,14 +120,14 @@ impl InternalEvent for ExecCommandExecuted<'_> { elapsed_millis = %self.exec_duration.as_millis(), ); counter!( - MetricName::CommandExecutedTotal, + CounterName::CommandExecutedTotal, "command" => self.command.to_owned(), "exit_status" => exit_status.clone(), ) .increment(1); histogram!( - MetricName::CommandExecutionDurationSeconds, + CounterName::CommandExecutionDurationSeconds, "exit_status" => exit_status, "command" => self.command.to_owned(), ) @@ -196,7 +196,7 @@ impl InternalEvent for ExecFailedToSignalChildError<'_> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "command" => format!("{:?}", self.command.as_std()), "error_code" => self.error.to_error_code(), "error_type" => error_type::COMMAND_FAILED, @@ -218,7 +218,7 @@ impl InternalEvent for ExecChannelClosedError { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/expansion.rs b/src/internal_events/expansion.rs index 568fcc0da7da1..7f5b48914c69c 100644 --- a/src/internal_events/expansion.rs +++ b/src/internal_events/expansion.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(NamedInternalEvent)] pub struct PairExpansionError<'a> { @@ -24,7 +24,7 @@ impl InternalEvent for PairExpansionError<'_> { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/file.rs b/src/internal_events/file.rs index 86b502f1273b0..5426f3c1eeda9 100644 --- a/src/internal_events/file.rs +++ b/src/internal_events/file.rs @@ -6,7 +6,7 @@ use vector_lib::{ NamedInternalEvent, configurable::configurable_component, internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, }; use vector_lib::{counter, gauge}; @@ -34,7 +34,7 @@ pub struct FileOpen { impl InternalEvent for FileOpen { fn emit(self) { - gauge!(MetricName::OpenFiles).set(self.count as f64); + gauge!(CounterName::OpenFiles).set(self.count as f64); } } @@ -55,13 +55,13 @@ impl InternalEvent for FileBytesSent<'_> { ); if self.include_file_metric_tag { counter!( - MetricName::ComponentSentBytesTotal, + CounterName::ComponentSentBytesTotal, "protocol" => "file", "file" => self.file.clone().into_owned(), ) } else { counter!( - MetricName::ComponentSentBytesTotal, + CounterName::ComponentSentBytesTotal, "protocol" => "file", ) } @@ -89,7 +89,7 @@ impl InternalEvent for FileIoError<'_, P> { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => self.code, "error_type" => error_type::IO_FAILED, "stage" => error_stage::SENDING, @@ -114,7 +114,9 @@ mod source { use vector_lib::{ NamedInternalEvent, emit, file_source_common::internal_events::FileSourceInternalEvents, - internal_event::{ComponentEventsDropped, INTENTIONAL, MetricName, error_stage, error_type}, + internal_event::{ + ComponentEventsDropped, CounterName, INTENTIONAL, error_stage, error_type, + }, json_size::JsonSize, }; @@ -137,13 +139,13 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "protocol" => "file", "file" => self.file.to_owned() ) } else { counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "protocol" => "file", ) } @@ -169,18 +171,18 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "file" => self.file.to_owned(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "file" => self.file.to_owned(), ) .increment(self.byte_size.get() as u64); } else { - counter!(MetricName::ComponentReceivedEventsTotal).increment(self.count as u64); - counter!(MetricName::ComponentReceivedEventBytesTotal) + counter!(CounterName::ComponentReceivedEventsTotal).increment(self.count as u64); + counter!(CounterName::ComponentReceivedEventBytesTotal) .increment(self.byte_size.get() as u64); } } @@ -200,11 +202,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::ChecksumErrorsTotal, + CounterName::ChecksumErrorsTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!(MetricName::ChecksumErrorsTotal) + counter!(CounterName::ChecksumErrorsTotal) } .increment(1); } @@ -229,7 +231,7 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "reading_fingerprint", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -237,7 +239,7 @@ mod source { ) } else { counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "reading_fingerprint", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -268,7 +270,7 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "file" => self.file.to_string_lossy().into_owned(), "error_code" => DELETION_FAILED, "error_type" => error_type::COMMAND_FAILED, @@ -276,7 +278,7 @@ mod source { ) } else { counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => DELETION_FAILED, "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, @@ -300,11 +302,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::FilesDeletedTotal, + CounterName::FilesDeletedTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!(MetricName::FilesDeletedTotal) + counter!(CounterName::FilesDeletedTotal) } .increment(1); } @@ -327,13 +329,13 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::FilesUnwatchedTotal, + CounterName::FilesUnwatchedTotal, "file" => self.file.to_string_lossy().into_owned(), "reached_eof" => reached_eof, ) } else { counter!( - MetricName::FilesUnwatchedTotal, + CounterName::FilesUnwatchedTotal, "reached_eof" => reached_eof, ) } @@ -360,7 +362,7 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "watching", "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, @@ -368,7 +370,7 @@ mod source { ) } else { counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "watching", "error_type" => error_type::COMMAND_FAILED, "stage" => error_stage::RECEIVING, @@ -394,11 +396,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::FilesResumedTotal, + CounterName::FilesResumedTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!(MetricName::FilesResumedTotal) + counter!(CounterName::FilesResumedTotal) } .increment(1); } @@ -418,11 +420,11 @@ mod source { ); if self.include_file_metric_tag { counter!( - MetricName::FilesAddedTotal, + CounterName::FilesAddedTotal, "file" => self.file.to_string_lossy().into_owned(), ) } else { - counter!(MetricName::FilesAddedTotal) + counter!(CounterName::FilesAddedTotal) } .increment(1); } @@ -441,7 +443,7 @@ mod source { count = %self.count, duration_ms = self.duration.as_millis() as u64, ); - counter!(MetricName::CheckpointsTotal).increment(self.count as u64); + counter!(CounterName::CheckpointsTotal).increment(self.count as u64); } } @@ -460,7 +462,7 @@ mod source { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "writing_checkpoints", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::RECEIVING, @@ -486,7 +488,7 @@ mod source { path = %self.path.display(), ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "globbing", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -513,7 +515,7 @@ mod source { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "reading_line_from_file", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/file_descriptor.rs b/src/internal_events/file_descriptor.rs index 7ed87349946b0..5a56ddbd267b1 100644 --- a/src/internal_events/file_descriptor.rs +++ b/src/internal_events/file_descriptor.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct FileDescriptorReadError { @@ -18,7 +18,7 @@ where stage = error_stage::RECEIVING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/fluent.rs b/src/internal_events/fluent.rs index 7c8ce8d23d9ce..7ba62f9d6c50f 100644 --- a/src/internal_events/fluent.rs +++ b/src/internal_events/fluent.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use crate::sources::fluent::DecodeError; @@ -30,7 +30,7 @@ impl InternalEvent for FluentMessageDecodeError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/gcp_pubsub.rs b/src/internal_events/gcp_pubsub.rs index 8c70dfd98120a..95901fbac9540 100644 --- a/src/internal_events/gcp_pubsub.rs +++ b/src/internal_events/gcp_pubsub.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(NamedInternalEvent)] pub struct GcpPubsubConnectError { @@ -17,7 +17,7 @@ impl InternalEvent for GcpPubsubConnectError { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_connecting", "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, @@ -42,7 +42,7 @@ impl InternalEvent for GcpPubsubStreamingPullError { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_streaming_pull", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -67,7 +67,7 @@ impl InternalEvent for GcpPubsubReceiveError { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_fetching_events", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/grpc.rs b/src/internal_events/grpc.rs index 93b948942ff79..1d66aa6a4f4e1 100644 --- a/src/internal_events/grpc.rs +++ b/src/internal_events/grpc.rs @@ -3,7 +3,7 @@ use std::time::Duration; use http::response::Response; use tonic::Code; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{counter, histogram}; const GRPC_STATUS_LABEL: &str = "grpc_status"; @@ -13,7 +13,7 @@ pub struct GrpcServerRequestReceived; impl InternalEvent for GrpcServerRequestReceived { fn emit(self) { - counter!(MetricName::GrpcServerMessagesReceivedTotal).increment(1); + counter!(CounterName::GrpcServerMessagesReceivedTotal).increment(1); } } @@ -34,8 +34,8 @@ impl InternalEvent for GrpcServerResponseSent<'_, B> { let grpc_code = grpc_code_to_name(grpc_code); let labels = &[(GRPC_STATUS_LABEL, grpc_code)]; - counter!(MetricName::GrpcServerMessagesSentTotal, labels).increment(1); - histogram!(MetricName::GrpcServerHandlerDurationSeconds, labels).record(self.latency); + counter!(CounterName::GrpcServerMessagesSentTotal, labels).increment(1); + histogram!(CounterName::GrpcServerHandlerDurationSeconds, labels).record(self.latency); } } @@ -53,7 +53,7 @@ impl InternalEvent for GrpcInvalidCompressionSchemeError<'_> { stage = error_stage::RECEIVING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) @@ -78,7 +78,7 @@ where stage = error_stage::RECEIVING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/heartbeat.rs b/src/internal_events/heartbeat.rs index 008f8cb18dbd8..25ead99b8fdd2 100644 --- a/src/internal_events/heartbeat.rs +++ b/src/internal_events/heartbeat.rs @@ -1,7 +1,7 @@ use std::time::Instant; +use vector_lib::internal_event::{CounterName, InternalEvent}; use vector_lib::{NamedInternalEvent, gauge}; -use vector_lib::internal_event::{InternalEvent, MetricName}; use crate::built_info; @@ -13,9 +13,9 @@ pub struct Heartbeat { impl InternalEvent for Heartbeat { fn emit(self) { trace!(target: "vector", message = "Beep."); - gauge!(MetricName::UptimeSeconds).set(self.since.elapsed().as_secs() as f64); + gauge!(CounterName::UptimeSeconds).set(self.since.elapsed().as_secs() as f64); gauge!( - MetricName::BuildInfo, + CounterName::BuildInfo, "debug" => built_info::DEBUG, "version" => built_info::PKG_VERSION, "rust_version" => built_info::RUST_VERSION, diff --git a/src/internal_events/host_metrics.rs b/src/internal_events/host_metrics.rs index 25b3bb3558d69..bfb432aabc43b 100644 --- a/src/internal_events/host_metrics.rs +++ b/src/internal_events/host_metrics.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct HostMetricsScrapeError { @@ -15,7 +15,7 @@ impl InternalEvent for HostMetricsScrapeError { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, ) @@ -39,7 +39,7 @@ impl InternalEvent for HostMetricsScrapeDetailError { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, ) @@ -65,7 +65,7 @@ impl InternalEvent for HostMetricsScrapeFilesystemError { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/http.rs b/src/internal_events/http.rs index 3dcc203dc9145..1a3fc59a2aa4c 100644 --- a/src/internal_events/http.rs +++ b/src/internal_events/http.rs @@ -3,7 +3,7 @@ use std::{error::Error, time::Duration}; use http::Response; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; use vector_lib::{counter, histogram}; @@ -16,7 +16,7 @@ pub struct HttpServerRequestReceived; impl InternalEvent for HttpServerRequestReceived { fn emit(self) { debug!(message = "Received HTTP request."); - counter!(MetricName::HttpServerRequestsReceivedTotal).increment(1); + counter!(CounterName::HttpServerRequestsReceivedTotal).increment(1); } } @@ -32,8 +32,8 @@ impl InternalEvent for HttpServerResponseSent<'_, B> { HTTP_STATUS_LABEL, self.response.status().as_u16().to_string(), )]; - counter!(MetricName::HttpServerResponsesSentTotal, labels).increment(1); - histogram!(MetricName::HttpServerHandlerDurationSeconds, labels).record(self.latency); + counter!(CounterName::HttpServerResponsesSentTotal, labels).increment(1); + histogram!(CounterName::HttpServerHandlerDurationSeconds, labels).record(self.latency); } } @@ -53,7 +53,7 @@ impl InternalEvent for HttpBytesReceived<'_> { protocol = %self.protocol ); counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "http_path" => self.http_path.to_string(), "protocol" => self.protocol, ) @@ -79,15 +79,15 @@ impl InternalEvent for HttpEventsReceived<'_> { protocol = %self.protocol, ); - histogram!(MetricName::ComponentReceivedEventsCount).record(self.count as f64); + histogram!(CounterName::ComponentReceivedEventsCount).record(self.count as f64); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "http_path" => self.http_path.to_string(), "protocol" => self.protocol, ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "http_path" => self.http_path.to_string(), "protocol" => self.protocol, ) @@ -126,7 +126,7 @@ impl InternalEvent for HttpBadRequest<'_> { http_code = %self.code, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::REQUEST_FAILED, "error_stage" => error_stage::RECEIVING, @@ -152,7 +152,7 @@ impl InternalEvent for HttpDecompressError<'_> { encoding = %self.encoding ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_decompressing_payload", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::RECEIVING, @@ -174,7 +174,7 @@ impl InternalEvent for HttpInternalError<'_> { stage = error_stage::RECEIVING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/http_client.rs b/src/internal_events/http_client.rs index d0e92c25b15e8..2d23d9a5a8129 100644 --- a/src/internal_events/http_client.rs +++ b/src/internal_events/http_client.rs @@ -6,7 +6,7 @@ use http::{ }; use hyper::{Error, body::HttpBody}; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{counter, histogram}; #[derive(Debug, NamedInternalEvent)] @@ -39,7 +39,7 @@ impl InternalEvent for AboutToSendHttpRequest<'_, T> { headers = ?remove_sensitive(self.request.headers()), body = %FormatBody(self.request.body()), ); - counter!(MetricName::HttpClientRequestsSentTotal, "method" => self.request.method().to_string()) + counter!(CounterName::HttpClientRequestsSentTotal, "method" => self.request.method().to_string()) .increment(1); } } @@ -60,13 +60,13 @@ impl InternalEvent for GotHttpResponse<'_, T> { body = %FormatBody(self.response.body()), ); counter!( - MetricName::HttpClientResponsesTotal, + CounterName::HttpClientResponsesTotal, "status" => self.response.status().as_u16().to_string(), ) .increment(1); - histogram!(MetricName::HttpClientRttSeconds).record(self.roundtrip); + histogram!(CounterName::HttpClientRttSeconds).record(self.roundtrip); histogram!( - MetricName::HttpClientResponseRttSeconds, + CounterName::HttpClientResponseRttSeconds, "status" => self.response.status().as_u16().to_string(), ) .record(self.roundtrip); @@ -87,10 +87,10 @@ impl InternalEvent for GotHttpWarning<'_> { error_type = error_type::REQUEST_FAILED, stage = error_stage::PROCESSING, ); - counter!(MetricName::HttpClientErrorsTotal, "error_kind" => self.error.to_string()) + counter!(CounterName::HttpClientErrorsTotal, "error_kind" => self.error.to_string()) .increment(1); - histogram!(MetricName::HttpClientRttSeconds).record(self.roundtrip); - histogram!(MetricName::HttpClientErrorRttSeconds, "error_kind" => self.error.to_string()) + histogram!(CounterName::HttpClientRttSeconds).record(self.roundtrip); + histogram!(CounterName::HttpClientErrorRttSeconds, "error_kind" => self.error.to_string()) .record(self.roundtrip); } } diff --git a/src/internal_events/http_client_source.rs b/src/internal_events/http_client_source.rs index c6260d97d5899..c0dace6fdae4f 100644 --- a/src/internal_events/http_client_source.rs +++ b/src/internal_events/http_client_source.rs @@ -3,7 +3,7 @@ use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; @@ -25,12 +25,12 @@ impl InternalEvent for HttpClientEventsReceived { url = %self.url, ); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "uri" => self.url.clone(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "uri" => self.url.clone(), ) .increment(self.byte_size.get() as u64); @@ -53,7 +53,7 @@ impl InternalEvent for HttpClientHttpResponseError { error_code = %http_error_code(self.code.as_u16()), ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "url" => self.url, "stage" => error_stage::RECEIVING, "error_type" => error_type::REQUEST_FAILED, @@ -79,7 +79,7 @@ impl InternalEvent for HttpClientHttpError { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "url" => self.url, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/influxdb.rs b/src/internal_events/influxdb.rs index adf713eb43f6e..a142642140f6f 100644 --- a/src/internal_events/influxdb.rs +++ b/src/internal_events/influxdb.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct InfluxdbEncodingError { @@ -19,7 +19,7 @@ impl InternalEvent for InfluxdbEncodingError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/internal_logs.rs b/src/internal_events/internal_logs.rs index 09ab5abaa5c3a..2f0674d380edd 100644 --- a/src/internal_events/internal_logs.rs +++ b/src/internal_events/internal_logs.rs @@ -1,4 +1,8 @@ -use vector_lib::{NamedInternalEvent, counter, internal_event::{InternalEvent, MetricName}, json_size::JsonSize}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent}, + json_size::JsonSize, +}; #[derive(Debug, NamedInternalEvent)] pub struct InternalLogsBytesReceived { @@ -9,7 +13,7 @@ impl InternalEvent for InternalLogsBytesReceived { fn emit(self) { // MUST NOT emit logs here to avoid an infinite log loop counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "protocol" => "internal", ) .increment(self.byte_size as u64); @@ -25,8 +29,8 @@ pub struct InternalLogsEventsReceived { impl InternalEvent for InternalLogsEventsReceived { fn emit(self) { // MUST NOT emit logs here to avoid an infinite log loop - counter!(MetricName::ComponentReceivedEventsTotal).increment(self.count as u64); - counter!(MetricName::ComponentReceivedEventBytesTotal) + counter!(CounterName::ComponentReceivedEventsTotal).increment(self.count as u64); + counter!(CounterName::ComponentReceivedEventBytesTotal) .increment(self.byte_size.get() as u64); } } diff --git a/src/internal_events/journald.rs b/src/internal_events/journald.rs index b0e4f23aca105..7e1ad8ce34561 100644 --- a/src/internal_events/journald.rs +++ b/src/internal_events/journald.rs @@ -2,7 +2,7 @@ use vector_lib::counter; use vector_lib::{ NamedInternalEvent, codecs::decoding::BoxedFramingError, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, }; #[derive(Debug, NamedInternalEvent)] @@ -21,7 +21,7 @@ impl InternalEvent for JournaldInvalidRecordError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::PARSER_FAILED, ) @@ -43,7 +43,7 @@ impl InternalEvent for JournaldStartJournalctlError { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::COMMAND_FAILED, ) @@ -65,7 +65,7 @@ impl InternalEvent for JournaldReadError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::READER_FAILED, ) @@ -89,7 +89,7 @@ impl InternalEvent for JournaldCheckpointSetError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::PROCESSING, "error_type" => error_type::IO_FAILED, ) @@ -113,7 +113,7 @@ impl InternalEvent for JournaldCheckpointFileOpenError { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "stage" => error_stage::RECEIVING, "error_type" => error_type::IO_FAILED, ) diff --git a/src/internal_events/kafka.rs b/src/internal_events/kafka.rs index 0415f809808e7..9da9ddab7167d 100644 --- a/src/internal_events/kafka.rs +++ b/src/internal_events/kafka.rs @@ -2,7 +2,7 @@ use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; use vector_lib::{counter, gauge}; @@ -26,7 +26,7 @@ impl InternalEvent for KafkaBytesReceived<'_> { partition = %self.partition, ); counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "protocol" => self.protocol, "topic" => self.topic.to_string(), "partition" => self.partition.to_string(), @@ -53,13 +53,13 @@ impl InternalEvent for KafkaEventsReceived<'_> { partition = %self.partition, ); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "topic" => self.topic.to_string(), "partition" => self.partition.to_string(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "topic" => self.topic.to_string(), "partition" => self.partition.to_string(), ) @@ -82,7 +82,7 @@ impl InternalEvent for KafkaOffsetUpdateError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "kafka_offset_update", "error_type" => error_type::READER_FAILED, "stage" => error_stage::SENDING, @@ -106,7 +106,7 @@ impl InternalEvent for KafkaReadError { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "reading_message", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -123,24 +123,24 @@ pub struct KafkaStatisticsReceived<'a> { impl InternalEvent for KafkaStatisticsReceived<'_> { fn emit(self) { - gauge!(MetricName::KafkaQueueMessages).set(self.statistics.msg_cnt as f64); - gauge!(MetricName::KafkaQueueMessagesBytes).set(self.statistics.msg_size as f64); - counter!(MetricName::KafkaRequestsTotal).absolute(self.statistics.tx as u64); - counter!(MetricName::KafkaRequestsBytesTotal).absolute(self.statistics.tx_bytes as u64); - counter!(MetricName::KafkaResponsesTotal).absolute(self.statistics.rx as u64); - counter!(MetricName::KafkaResponsesBytesTotal).absolute(self.statistics.rx_bytes as u64); - counter!(MetricName::KafkaProducedMessagesTotal).absolute(self.statistics.txmsgs as u64); - counter!(MetricName::KafkaProducedMessagesBytesTotal) + gauge!(CounterName::KafkaQueueMessages).set(self.statistics.msg_cnt as f64); + gauge!(CounterName::KafkaQueueMessagesBytes).set(self.statistics.msg_size as f64); + counter!(CounterName::KafkaRequestsTotal).absolute(self.statistics.tx as u64); + counter!(CounterName::KafkaRequestsBytesTotal).absolute(self.statistics.tx_bytes as u64); + counter!(CounterName::KafkaResponsesTotal).absolute(self.statistics.rx as u64); + counter!(CounterName::KafkaResponsesBytesTotal).absolute(self.statistics.rx_bytes as u64); + counter!(CounterName::KafkaProducedMessagesTotal).absolute(self.statistics.txmsgs as u64); + counter!(CounterName::KafkaProducedMessagesBytesTotal) .absolute(self.statistics.txmsg_bytes as u64); - counter!(MetricName::KafkaConsumedMessagesTotal).absolute(self.statistics.rxmsgs as u64); - counter!(MetricName::KafkaConsumedMessagesBytesTotal) + counter!(CounterName::KafkaConsumedMessagesTotal).absolute(self.statistics.rxmsgs as u64); + counter!(CounterName::KafkaConsumedMessagesBytesTotal) .absolute(self.statistics.rxmsg_bytes as u64); if self.expose_lag_metrics { for (topic_id, topic) in &self.statistics.topics { for (partition_id, partition) in &topic.partitions { gauge!( - MetricName::KafkaConsumerLag, + CounterName::KafkaConsumerLag, "topic_id" => topic_id.clone(), "partition_id" => partition_id.to_string(), ) @@ -166,7 +166,7 @@ impl InternalEvent for KafkaHeaderExtractionError<'_> { header_field = self.header_field.to_string(), ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "extracting_header", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/kubernetes_logs.rs b/src/internal_events/kubernetes_logs.rs index cd21435ccbfc8..79920ddfae182 100644 --- a/src/internal_events/kubernetes_logs.rs +++ b/src/internal_events/kubernetes_logs.rs @@ -2,7 +2,8 @@ use vector_lib::counter; use vector_lib::{ NamedInternalEvent, internal_event::{ - ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent, UNINTENTIONAL, + error_stage, error_type, }, json_size::JsonSize, }; @@ -37,21 +38,21 @@ impl InternalEvent for KubernetesLogsEventsReceived<'_> { let pod_namespace = pod_info.namespace; counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "pod_name" => pod_name.clone(), "pod_namespace" => pod_namespace.clone(), ) .increment(1); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "pod_name" => pod_name, "pod_namespace" => pod_namespace, ) .increment(self.byte_size.get() as u64); } None => { - counter!(MetricName::ComponentReceivedEventsTotal).increment(1); - counter!(MetricName::ComponentReceivedEventBytesTotal) + counter!(CounterName::ComponentReceivedEventsTotal).increment(1); + counter!(CounterName::ComponentReceivedEventBytesTotal) .increment(self.byte_size.get() as u64); } } @@ -75,7 +76,7 @@ impl InternalEvent for KubernetesLogsEventAnnotationError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => ANNOTATION_FAILED, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, @@ -99,13 +100,13 @@ impl InternalEvent for KubernetesLogsEventNamespaceAnnotationError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => ANNOTATION_FAILED, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, ) .increment(1); - counter!(MetricName::K8sEventNamespaceAnnotationFailuresTotal).increment(1); + counter!(CounterName::K8sEventNamespaceAnnotationFailuresTotal).increment(1); } } @@ -124,13 +125,13 @@ impl InternalEvent for KubernetesLogsEventNodeAnnotationError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => ANNOTATION_FAILED, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, ) .increment(1); - counter!(MetricName::K8sEventNodeAnnotationFailuresTotal).increment(1); + counter!(CounterName::K8sEventNodeAnnotationFailuresTotal).increment(1); } } @@ -145,7 +146,7 @@ impl InternalEvent for KubernetesLogsFormatPickerEdgeCase { message = "Encountered format picker edge case.", what = %self.what, ); - counter!(MetricName::K8sFormatPickerEdgeCasesTotal).increment(1); + counter!(CounterName::K8sFormatPickerEdgeCasesTotal).increment(1); } } @@ -163,12 +164,12 @@ impl InternalEvent for KubernetesLogsDockerFormatParseError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) .increment(1); - counter!(MetricName::K8sDockerFormatParseFailuresTotal).increment(1); + counter!(CounterName::K8sDockerFormatParseFailuresTotal).increment(1); } } @@ -191,7 +192,7 @@ impl InternalEvent for KubernetesLifecycleError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => KUBERNETES_LIFECYCLE, "error_type" => error_type::READER_FAILED, "stage" => error_stage::PROCESSING, @@ -222,7 +223,7 @@ impl InternalEvent for KubernetesMergedLineTooBigError<'_> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "reading_line_from_kubernetes_log", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/log_to_metric.rs b/src/internal_events/log_to_metric.rs index 51717fa0c1ffa..e766d3b15eea1 100644 --- a/src/internal_events/log_to_metric.rs +++ b/src/internal_events/log_to_metric.rs @@ -2,7 +2,7 @@ use std::num::ParseFloatError; use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }; #[derive(NamedInternalEvent)] @@ -21,7 +21,7 @@ impl InternalEvent for LogToMetricFieldNullError<'_> { null_field = %self.field ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "field_null", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -51,7 +51,7 @@ impl InternalEvent for LogToMetricParseFloatError<'_> { stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "failed_parsing_float", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -82,7 +82,7 @@ impl InternalEvent for MetricMetadataInvalidFieldValueError<'_> { stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "invalid_field_value", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -111,7 +111,7 @@ impl InternalEvent for MetricMetadataParseError<'_> { stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => format!("failed_parsing_{}", self.kind), "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -136,7 +136,7 @@ impl InternalEvent for MetricMetadataMetricDetailsNotFoundError { stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "missing_metric_details", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/logplex.rs b/src/internal_events/logplex.rs index 256fe088598ed..e47c62284051f 100644 --- a/src/internal_events/logplex.rs +++ b/src/internal_events/logplex.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use super::prelude::io_error_code; @@ -36,7 +36,7 @@ impl InternalEvent for HerokuLogplexRequestReadError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::READER_FAILED, "error_code" => io_error_code(&self.error), "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/loki.rs b/src/internal_events/loki.rs index 70ffd98c340b2..a110f5c95d8c4 100644 --- a/src/internal_events/loki.rs +++ b/src/internal_events/loki.rs @@ -1,6 +1,6 @@ use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName, error_stage, error_type, + ComponentEventsDropped, INTENTIONAL, InternalEvent, CounterName, error_stage, error_type, }; #[derive(Debug, NamedInternalEvent)] @@ -16,7 +16,7 @@ impl InternalEvent for LokiEventUnlabeledError { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "unlabeled_event", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -47,7 +47,7 @@ impl InternalEvent for LokiOutOfOrderEventDroppedError { }); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "out_of_order", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -68,7 +68,7 @@ impl InternalEvent for LokiOutOfOrderEventRewritten { count = self.count, reason = "out_of_order", ); - counter!(MetricName::RewrittenTimestampEventsTotal).increment(self.count as u64); + counter!(CounterName::RewrittenTimestampEventsTotal).increment(self.count as u64); } } @@ -89,7 +89,7 @@ impl InternalEvent for LokiTimestampNonParsableEventsDropped { emit!(ComponentEventsDropped:: { count: 1, reason }); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "non-parsable_timestamp", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/lua.rs b/src/internal_events/lua.rs index 9447d193a79d5..a2052272be76f 100644 --- a/src/internal_events/lua.rs +++ b/src/internal_events/lua.rs @@ -1,6 +1,6 @@ use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use vector_lib::{counter, gauge}; @@ -13,7 +13,7 @@ pub struct LuaGcTriggered { impl InternalEvent for LuaGcTriggered { fn emit(self) { - gauge!(MetricName::LuaMemoryUsedBytes).set(self.used_memory as f64); + gauge!(CounterName::LuaMemoryUsedBytes).set(self.used_memory as f64); } } @@ -32,7 +32,7 @@ impl InternalEvent for LuaScriptError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => mlua_error_code(&self.error), "error_type" => error_type::SCRIPT_FAILED, "stage" => error_stage::PROCESSING, @@ -62,7 +62,7 @@ impl InternalEvent for LuaBuildError { internal_log_rate_limit = false, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => lua_build_error_code(&self.error), "error_type" => error_type::SCRIPT_FAILED, "stage" => error_stage:: PROCESSING, diff --git a/src/internal_events/metric_to_log.rs b/src/internal_events/metric_to_log.rs index 7f8ac1a5c84da..a11ed286be17a 100644 --- a/src/internal_events/metric_to_log.rs +++ b/src/internal_events/metric_to_log.rs @@ -1,8 +1,8 @@ use serde_json::Error; -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct MetricToLogSerializeError { @@ -19,7 +19,7 @@ impl InternalEvent for MetricToLogSerializeError { stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/mongodb_metrics.rs b/src/internal_events/mongodb_metrics.rs index a40c95ae86b08..0e314937ab831 100644 --- a/src/internal_events/mongodb_metrics.rs +++ b/src/internal_events/mongodb_metrics.rs @@ -2,7 +2,7 @@ use mongodb::{bson, error::Error as MongoError}; use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; @@ -23,12 +23,12 @@ impl InternalEvent for MongoDbMetricsEventsReceived<'_> { endpoint = self.endpoint, ); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -51,7 +51,7 @@ impl InternalEvent for MongoDbMetricsRequestError<'_> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) @@ -75,7 +75,7 @@ impl InternalEvent for MongoDbMetricsBsonParseError<'_> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::RECEIVING, "endpoint" => self.endpoint.to_owned(), diff --git a/src/internal_events/mqtt.rs b/src/internal_events/mqtt.rs index ef08fcf28f426..b82b321f1de70 100644 --- a/src/internal_events/mqtt.rs +++ b/src/internal_events/mqtt.rs @@ -1,8 +1,8 @@ use std::fmt::Debug; use rumqttc::ConnectionError; +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct MqttConnectionError { @@ -19,7 +19,7 @@ impl InternalEvent for MqttConnectionError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "mqtt_connection_error", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, diff --git a/src/internal_events/nginx_metrics.rs b/src/internal_events/nginx_metrics.rs index 4e4649cd539be..6b58cff4a741a 100644 --- a/src/internal_events/nginx_metrics.rs +++ b/src/internal_events/nginx_metrics.rs @@ -1,7 +1,7 @@ use vector_lib::counter; use vector_lib::{ NamedInternalEvent, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; @@ -23,12 +23,12 @@ impl InternalEvent for NginxMetricsEventsReceived<'_> { endpoint = self.endpoint, ); counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.count as u64); counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "endpoint" => self.endpoint.to_owned(), ) .increment(self.byte_size.get() as u64); @@ -51,7 +51,7 @@ impl InternalEvent for NginxMetricsRequestError<'_> { stage = error_stage::RECEIVING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "endpoint" => self.endpoint.to_owned(), "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -76,7 +76,7 @@ impl InternalEvent for NginxMetricsStubStatusParseError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "endpoint" => self.endpoint.to_owned(), "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/open.rs b/src/internal_events/open.rs index a355905a135f4..eb55bbda12700 100644 --- a/src/internal_events/open.rs +++ b/src/internal_events/open.rs @@ -6,8 +6,8 @@ use std::{ }, }; +use vector_lib::internal_event::{CounterName, InternalEvent}; use vector_lib::{NamedInternalEvent, gauge}; -use vector_lib::internal_event::{InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub struct ConnectionOpen { @@ -16,7 +16,7 @@ pub struct ConnectionOpen { impl InternalEvent for ConnectionOpen { fn emit(self) { - gauge!(MetricName::OpenConnections).set(self.count as f64); + gauge!(CounterName::OpenConnections).set(self.count as f64); } } @@ -27,7 +27,7 @@ pub struct EndpointsActive { impl InternalEvent for EndpointsActive { fn emit(self) { - gauge!(MetricName::ActiveEndpoints).set(self.count as f64); + gauge!(CounterName::ActiveEndpoints).set(self.count as f64); } } diff --git a/src/internal_events/parser.rs b/src/internal_events/parser.rs index 95536e9f993b0..ec538894b7e51 100644 --- a/src/internal_events/parser.rs +++ b/src/internal_events/parser.rs @@ -4,7 +4,7 @@ use std::borrow::Cow; use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }; fn truncate_string_at(s: &str, maxlen: usize) -> Cow<'_, str> { @@ -35,7 +35,7 @@ impl InternalEvent for ParserMatchError<'_> { field = &truncate_string_at(&String::from_utf8_lossy(self.value), 60)[..] ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "no_match_found", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -65,7 +65,7 @@ impl InternalEvent for ParserMissingFieldError<'_, DROP_ stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "field_not_found", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, @@ -96,7 +96,7 @@ impl InternalEvent for ParserConversionError<'_> { stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "type_conversion", "error_type" => error_type::CONVERSION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/postgresql_metrics.rs b/src/internal_events/postgresql_metrics.rs index 8d8d478454127..fddaedf3a698b 100644 --- a/src/internal_events/postgresql_metrics.rs +++ b/src/internal_events/postgresql_metrics.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct PostgresqlMetricsCollectError<'a> { @@ -17,7 +17,7 @@ impl InternalEvent for PostgresqlMetricsCollectError<'_> { endpoint = %self.endpoint, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/process.rs b/src/internal_events/process.rs index 22e765c6c2315..f0c40c210ce1b 100644 --- a/src/internal_events/process.rs +++ b/src/internal_events/process.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use crate::{built_info, config}; @@ -16,7 +16,7 @@ impl InternalEvent for VectorStarted { arch = built_info::TARGET_ARCH, revision = built_info::VECTOR_BUILD_DESC.unwrap_or(""), ); - counter!(MetricName::StartedTotal).increment(1); + counter!(CounterName::StartedTotal).increment(1); } } @@ -33,7 +33,7 @@ impl InternalEvent for VectorReloaded<'_> { path = ?self.config_paths, internal_log_rate_limit = false, ); - counter!(MetricName::ReloadedTotal).increment(1); + counter!(CounterName::ReloadedTotal).increment(1); } } @@ -58,7 +58,7 @@ impl InternalEvent for VectorStopped { target: "vector", message = "Vector has stopped.", ); - counter!(MetricName::StoppedTotal).increment(1); + counter!(CounterName::StoppedTotal).increment(1); } } @@ -71,7 +71,7 @@ impl InternalEvent for VectorQuit { target: "vector", message = "Vector has quit.", ); - counter!(MetricName::QuitTotal).increment(1); + counter!(CounterName::QuitTotal).increment(1); } } @@ -91,7 +91,7 @@ impl InternalEvent for VectorReloadError { internal_log_rate_limit = false, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "reload", "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::PROCESSING, @@ -114,7 +114,7 @@ impl InternalEvent for VectorConfigLoadError { internal_log_rate_limit = false, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "config_load", "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::PROCESSING, @@ -136,7 +136,7 @@ impl InternalEvent for VectorRecoveryError { internal_log_rate_limit = false, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "recovery", "error_type" => error_type::CONFIGURATION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/prometheus.rs b/src/internal_events/prometheus.rs index bd142e06e8d6e..9bcf6d878e819 100644 --- a/src/internal_events/prometheus.rs +++ b/src/internal_events/prometheus.rs @@ -5,7 +5,7 @@ use std::borrow::Cow; use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }; #[cfg(feature = "sources-prometheus-scrape")] use vector_lib::prometheus::parser::ParserError; @@ -33,7 +33,7 @@ impl InternalEvent for PrometheusParseError<'_> { url = %self.url ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, "url" => self.url.to_string(), @@ -56,7 +56,7 @@ impl InternalEvent for PrometheusRemoteWriteParseError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) @@ -76,7 +76,7 @@ impl InternalEvent for PrometheusNormalizationError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONVERSION_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/pulsar.rs b/src/internal_events/pulsar.rs index 825d9ff3af6ba..0e2e11b061f3e 100644 --- a/src/internal_events/pulsar.rs +++ b/src/internal_events/pulsar.rs @@ -2,10 +2,10 @@ #[cfg(feature = "sources-pulsar")] use metrics::Counter; -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct PulsarSendingError { @@ -23,7 +23,7 @@ impl InternalEvent for PulsarSendingError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::SENDING, ) @@ -50,7 +50,7 @@ impl InternalEvent for PulsarPropertyExtractionError { property_field = %self.property_field, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "extracting_property", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -76,21 +76,21 @@ pub struct PulsarErrorEventData { registered_event!( PulsarErrorEvent => { ack_errors: Counter = counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "acknowledge_message", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::RECEIVING, ), nack_errors: Counter = counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "negative_acknowledge_message", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::RECEIVING, ), read_errors: Counter = counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "reading_message", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/redis.rs b/src/internal_events/redis.rs index 1ecfbe34574cd..e7bafbd72f241 100644 --- a/src/internal_events/redis.rs +++ b/src/internal_events/redis.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; #[derive(Debug, NamedInternalEvent)] pub struct RedisReceiveEventError { @@ -24,7 +24,7 @@ impl InternalEvent for RedisReceiveEventError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => self.error_code, "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, diff --git a/src/internal_events/reduce.rs b/src/internal_events/reduce.rs index e9882799682ad..8dbb06bc652c0 100644 --- a/src/internal_events/reduce.rs +++ b/src/internal_events/reduce.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; use vrl::{path::PathParseError, value::KeyString}; #[derive(Debug, NamedInternalEvent)] @@ -7,7 +7,7 @@ pub struct ReduceStaleEventFlushed; impl InternalEvent for ReduceStaleEventFlushed { fn emit(self) { - counter!(MetricName::StaleEventsFlushedTotal).increment(1); + counter!(CounterName::StaleEventsFlushedTotal).increment(1); } } @@ -27,7 +27,7 @@ impl InternalEvent for ReduceAddEventError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/remap.rs b/src/internal_events/remap.rs index 6c4156c0d8b90..d0e6500d69341 100644 --- a/src/internal_events/remap.rs +++ b/src/internal_events/remap.rs @@ -1,7 +1,8 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, + error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct RemapMappingError { @@ -20,7 +21,7 @@ impl InternalEvent for RemapMappingError { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONVERSION_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/sematext_metrics.rs b/src/internal_events/sematext_metrics.rs index cfff591fff8ab..bfbd7b09e340f 100644 --- a/src/internal_events/sematext_metrics.rs +++ b/src/internal_events/sematext_metrics.rs @@ -1,6 +1,6 @@ use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }; use crate::event::metric::Metric; @@ -22,7 +22,7 @@ impl InternalEvent for SematextMetricsInvalidMetricError<'_> { kind = ?self.metric.kind(), ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "invalid_metric", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, @@ -48,7 +48,7 @@ impl InternalEvent for SematextMetricsEncodeEventError stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/socket.rs b/src/internal_events/socket.rs index 66762eb8d2fc1..92e821fec32f8 100644 --- a/src/internal_events/socket.rs +++ b/src/internal_events/socket.rs @@ -3,7 +3,7 @@ use std::net::Ipv4Addr; use vector_lib::{ NamedInternalEvent, internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; @@ -42,11 +42,11 @@ impl InternalEvent for SocketBytesReceived { %protocol, ); counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "protocol" => protocol, ) .increment(self.byte_size as u64); - histogram!(MetricName::ComponentReceivedBytes).record(self.byte_size as f64); + histogram!(CounterName::ComponentReceivedBytes).record(self.byte_size as f64); } } @@ -66,11 +66,11 @@ impl InternalEvent for SocketEventsReceived { byte_size = self.byte_size.get(), %mode, ); - counter!(MetricName::ComponentReceivedEventsTotal, "mode" => mode) + counter!(CounterName::ComponentReceivedEventsTotal, "mode" => mode) .increment(self.count as u64); - counter!(MetricName::ComponentReceivedEventBytesTotal, "mode" => mode) + counter!(CounterName::ComponentReceivedEventBytesTotal, "mode" => mode) .increment(self.byte_size.get() as u64); - histogram!(MetricName::ComponentReceivedBytes, "mode" => mode) + histogram!(CounterName::ComponentReceivedBytes, "mode" => mode) .record(self.byte_size.get() as f64); } } @@ -90,7 +90,7 @@ impl InternalEvent for SocketBytesSent { %protocol, ); counter!( - MetricName::ComponentSentBytesTotal, + CounterName::ComponentSentBytesTotal, "protocol" => protocol, ) .increment(self.byte_size as u64); @@ -107,9 +107,9 @@ pub struct SocketEventsSent { impl InternalEvent for SocketEventsSent { fn emit(self) { trace!(message = "Events sent.", count = %self.count, byte_size = %self.byte_size.get()); - counter!(MetricName::ComponentSentEventsTotal, "mode" => self.mode.as_str()) + counter!(CounterName::ComponentSentEventsTotal, "mode" => self.mode.as_str()) .increment(self.count); - counter!(MetricName::ComponentSentEventBytesTotal, "mode" => self.mode.as_str()) + counter!(CounterName::ComponentSentEventBytesTotal, "mode" => self.mode.as_str()) .increment(self.byte_size.get() as u64); } } @@ -132,7 +132,7 @@ impl InternalEvent for SocketBindError { %mode, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "socket_bind", "error_type" => error_type::IO_FAILED, "stage" => error_stage::INITIALIZING, @@ -167,7 +167,7 @@ impl InternalEvent for SocketMulticastGroupJoinError { %interface, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "socket_multicast_group_join", "error_type" => error_type::IO_FAILED, "stage" => error_stage::INITIALIZING, @@ -197,7 +197,7 @@ impl InternalEvent for SocketReceiveError { %mode, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "socket_receive", "error_type" => error_type::READER_FAILED, "stage" => error_stage::RECEIVING, @@ -226,7 +226,7 @@ impl InternalEvent for SocketSendError { %mode, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "socket_send", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index 95a1336577f86..4f57078812a8c 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -10,7 +10,7 @@ mod sink { use serde_json::Error; use vector_lib::{NamedInternalEvent, counter, gauge}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }; use crate::{ @@ -34,7 +34,7 @@ mod sink { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "serializing_json", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, @@ -62,13 +62,13 @@ mod sink { kind = ?self.kind, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::INVALID_METRIC, "stage" => error_stage::PROCESSING, ) .increment(1); counter!( - MetricName::ComponentDiscardedEventsTotal, + CounterName::ComponentDiscardedEventsTotal, "error_type" => error_type::INVALID_METRIC, "stage" => error_stage::PROCESSING, ) @@ -91,7 +91,7 @@ mod sink { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "invalid_response", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::SENDING, @@ -116,7 +116,7 @@ mod sink { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "indexer_ack_failed", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::SENDING, @@ -140,7 +140,7 @@ mod sink { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "indexer_ack_unavailable", "error_type" => error_type::ACKNOWLEDGMENT_FAILED, "stage" => error_stage::SENDING, @@ -154,7 +154,7 @@ mod sink { impl InternalEvent for SplunkIndexerAcknowledgementAckAdded { fn emit(self) { - gauge!(MetricName::SplunkPendingAcks).increment(1.0); + gauge!(CounterName::SplunkPendingAcks).increment(1.0); } } @@ -165,7 +165,7 @@ mod sink { impl InternalEvent for SplunkIndexerAcknowledgementAcksRemoved { fn emit(self) { - gauge!(MetricName::SplunkPendingAcks).decrement(self.count); + gauge!(CounterName::SplunkPendingAcks).decrement(self.count); } } @@ -197,7 +197,7 @@ mod sink { #[cfg(feature = "sources-splunk_hec")] mod source { use vector_lib::{NamedInternalEvent, counter}; - use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; + use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; use crate::sources::splunk_hec::ApiError; @@ -216,7 +216,7 @@ mod source { stage = error_stage::PROCESSING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "invalid_request_body", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -241,7 +241,7 @@ mod source { stage = error_stage::RECEIVING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::AUTHENTICATION_FAILED, "stage" => error_stage::RECEIVING, ) @@ -255,7 +255,7 @@ mod source { stage = error_stage::RECEIVING ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, ) diff --git a/src/internal_events/statsd_sink.rs b/src/internal_events/statsd_sink.rs index a80acf0c4225b..858084124b562 100644 --- a/src/internal_events/statsd_sink.rs +++ b/src/internal_events/statsd_sink.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; use crate::event::metric::{MetricKind, MetricValue}; @@ -23,7 +23,7 @@ impl InternalEvent for StatsdInvalidMetricError<'_> { kind = ?self.kind, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "invalid_metric", "error_type" => error_type::ENCODER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/tag_cardinality_limit.rs b/src/internal_events/tag_cardinality_limit.rs index 2498bc6aa8724..30951ed642fd9 100644 --- a/src/internal_events/tag_cardinality_limit.rs +++ b/src/internal_events/tag_cardinality_limit.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName}; #[derive(NamedInternalEvent)] pub struct TagCardinalityLimitRejectingEvent<'a> { @@ -19,13 +19,13 @@ impl InternalEvent for TagCardinalityLimitRejectingEvent<'_> { ); if self.include_extended_tags { counter!( - MetricName::TagValueLimitExceededTotal, + CounterName::TagValueLimitExceededTotal, "metric_name" => self.metric_name.to_string(), "tag_key" => self.tag_key.to_string(), ) .increment(1); } else { - counter!(MetricName::TagValueLimitExceededTotal).increment(1); + counter!(CounterName::TagValueLimitExceededTotal).increment(1); } emit!(ComponentEventsDropped:: { @@ -53,13 +53,13 @@ impl InternalEvent for TagCardinalityLimitRejectingTag<'_> { ); if self.include_extended_tags { counter!( - MetricName::TagValueLimitExceededTotal, + CounterName::TagValueLimitExceededTotal, "metric_name" => self.metric_name.to_string(), "tag_key" => self.tag_key.to_string(), ) .increment(1); } else { - counter!(MetricName::TagValueLimitExceededTotal).increment(1); + counter!(CounterName::TagValueLimitExceededTotal).increment(1); } } } @@ -75,6 +75,6 @@ impl InternalEvent for TagCardinalityValueLimitReached<'_> { message = "Value_limit reached for key. New values for this key will be rejected.", key = %self.key, ); - counter!(MetricName::ValueLimitReachedTotal).increment(1); + counter!(CounterName::ValueLimitReachedTotal).increment(1); } } diff --git a/src/internal_events/tcp.rs b/src/internal_events/tcp.rs index 0bc3d751c6509..6c754b8c0817b 100644 --- a/src/internal_events/tcp.rs +++ b/src/internal_events/tcp.rs @@ -1,7 +1,7 @@ use std::net::SocketAddr; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; use crate::{internal_events::SocketOutgoingConnectionError, tls::TlsError}; @@ -17,7 +17,7 @@ impl InternalEvent for TcpSocketConnectionEstablished { } else { debug!(message = "Connected.", peer_addr = "unknown"); } - counter!(MetricName::ConnectionEstablishedTotal, "mode" => "tcp").increment(1); + counter!(CounterName::ConnectionEstablishedTotal, "mode" => "tcp").increment(1); } } @@ -40,7 +40,7 @@ pub struct TcpSocketConnectionShutdown; impl InternalEvent for TcpSocketConnectionShutdown { fn emit(self) { warn!(message = "Received EOF from the server, shutdown."); - counter!(MetricName::ConnectionShutdownTotal, "mode" => "tcp").increment(1); + counter!(CounterName::ConnectionShutdownTotal, "mode" => "tcp").increment(1); } } @@ -62,7 +62,7 @@ impl InternalEvent for TcpSocketError<'_, E> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::PROCESSING, ) @@ -99,7 +99,7 @@ impl InternalEvent for TcpSocketTlsConnectionError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "connection_failed", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -126,7 +126,7 @@ impl InternalEvent for TcpSendAckError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "ack_failed", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -151,7 +151,7 @@ impl InternalEvent for TcpBytesReceived { peer_addr = %self.peer_addr, ); counter!( - MetricName::ComponentReceivedBytesTotal, "protocol" => "tcp" + CounterName::ComponentReceivedBytesTotal, "protocol" => "tcp" ) .increment(self.byte_size as u64); } diff --git a/src/internal_events/template.rs b/src/internal_events/template.rs index 7e5bab163dab9..6f04fb2628dd2 100644 --- a/src/internal_events/template.rs +++ b/src/internal_events/template.rs @@ -1,6 +1,6 @@ use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }; #[derive(NamedInternalEvent)] @@ -28,7 +28,7 @@ impl InternalEvent for TemplateRenderingError<'_> { ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::TEMPLATE_FAILED, "stage" => error_stage::PROCESSING, ) diff --git a/src/internal_events/throttle.rs b/src/internal_events/throttle.rs index b684dc3df77d1..a04db768ca762 100644 --- a/src/internal_events/throttle.rs +++ b/src/internal_events/throttle.rs @@ -1,5 +1,5 @@ +use vector_lib::internal_event::{ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent}; use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent, MetricName}; #[derive(Debug, NamedInternalEvent)] pub(crate) struct ThrottleEventDiscarded { @@ -22,7 +22,7 @@ impl InternalEvent for ThrottleEventDiscarded { // if we should change the specification wording? Sort of a similar situation to the // `error_code` tag for the component errors metric, where it's meant to be optional and // only specified when relevant. - counter!(MetricName::EventsDiscardedTotal, "key" => self.key).increment(1); // Deprecated. + counter!(CounterName::EventsDiscardedTotal, "key" => self.key).increment(1); // Deprecated. } emit!(ComponentEventsDropped:: { diff --git a/src/internal_events/udp.rs b/src/internal_events/udp.rs index e91d00b9a3e65..d4ae75d38e4b5 100644 --- a/src/internal_events/udp.rs +++ b/src/internal_events/udp.rs @@ -1,6 +1,6 @@ use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, }; use crate::internal_events::SocketOutgoingConnectionError; @@ -13,7 +13,7 @@ pub struct UdpSocketConnectionEstablished; impl InternalEvent for UdpSocketConnectionEstablished { fn emit(self) { debug!(message = "Connected."); - counter!(MetricName::ConnectionEstablishedTotal, "mode" => "udp").increment(1); + counter!(CounterName::ConnectionEstablishedTotal, "mode" => "udp").increment(1); } } @@ -50,13 +50,13 @@ impl InternalEvent for UdpSendIncompleteError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) .increment(1); // deprecated - counter!(MetricName::ConnectionSendErrorsTotal, "mode" => "udp").increment(1); + counter!(CounterName::ConnectionSendErrorsTotal, "mode" => "udp").increment(1); emit!(ComponentEventsDropped:: { count: 1, reason }); } @@ -79,7 +79,7 @@ impl InternalEvent for UdpChunkingError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) diff --git a/src/internal_events/unix.rs b/src/internal_events/unix.rs index c0709e90b2baf..fc98ff7feacbd 100644 --- a/src/internal_events/unix.rs +++ b/src/internal_events/unix.rs @@ -2,10 +2,10 @@ use std::{io::Error, path::Path}; -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, MetricName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; use crate::internal_events::SocketOutgoingConnectionError; @@ -17,7 +17,7 @@ pub struct UnixSocketConnectionEstablished<'a> { impl InternalEvent for UnixSocketConnectionEstablished<'_> { fn emit(self) { debug!(message = "Connected.", path = ?self.path); - counter!(MetricName::ConnectionEstablishedTotal, "mode" => "unix").increment(1); + counter!(CounterName::ConnectionEstablishedTotal, "mode" => "unix").increment(1); } } @@ -58,7 +58,7 @@ impl InternalEvent for UnixSocketError<'_, E> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::CONNECTION_FAILED, "stage" => error_stage::PROCESSING, ) @@ -83,7 +83,7 @@ impl InternalEvent for UnixSocketSendError<'_, E> { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) @@ -111,7 +111,7 @@ impl InternalEvent for UnixSendIncompleteError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, ) @@ -138,7 +138,7 @@ impl InternalEvent for UnixSocketFileDeleteError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "delete_socket_file", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/websocket.rs b/src/internal_events/websocket.rs index 892eba3ecf3b0..bb32a990ea069 100644 --- a/src/internal_events/websocket.rs +++ b/src/internal_events/websocket.rs @@ -11,7 +11,7 @@ use vector_common::{ json_size::JsonSize, }; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, MetricName}; +use vector_lib::internal_event::{CounterName, InternalEvent}; use vector_lib::{counter, histogram}; pub const PROTOCOL: &str = "websocket"; @@ -22,7 +22,7 @@ pub struct WebSocketConnectionEstablished; impl InternalEvent for WebSocketConnectionEstablished { fn emit(self) { debug!(message = "Connected."); - counter!(MetricName::ConnectionEstablishedTotal).increment(1); + counter!(CounterName::ConnectionEstablishedTotal).increment(1); } } @@ -41,7 +41,7 @@ impl InternalEvent for WebSocketConnectionFailedError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_connection_failed", "error_type" => error_type::CONNECTION_FAILED, @@ -57,7 +57,7 @@ pub struct WebSocketConnectionShutdown; impl InternalEvent for WebSocketConnectionShutdown { fn emit(self) { warn!(message = "Closed by the server."); - counter!(MetricName::ConnectionShutdownTotal).increment(1); + counter!(CounterName::ConnectionShutdownTotal).increment(1); } } @@ -76,7 +76,7 @@ impl InternalEvent for WebSocketConnectionError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_connection_error", "error_type" => error_type::WRITER_FAILED, @@ -121,7 +121,7 @@ impl InternalEvent for WebSocketBytesReceived<'_> { kind = %self.kind ); let counter = counter!( - MetricName::ComponentReceivedBytesTotal, + CounterName::ComponentReceivedBytesTotal, "url" => self.url.to_string(), "protocol" => self.protocol, "kind" => self.kind.to_string() @@ -150,17 +150,17 @@ impl InternalEvent for WebSocketMessageReceived<'_> { kind = %self.kind ); - let histogram = histogram!(MetricName::ComponentReceivedEventsCount); + let histogram = histogram!(CounterName::ComponentReceivedEventsCount); histogram.record(self.count as f64); let counter = counter!( - MetricName::ComponentReceivedEventsTotal, + CounterName::ComponentReceivedEventsTotal, "uri" => self.url.to_string(), "protocol" => PROTOCOL, "kind" => self.kind.to_string() ); counter.increment(self.count as u64); let counter = counter!( - MetricName::ComponentReceivedEventBytesTotal, + CounterName::ComponentReceivedEventBytesTotal, "url" => self.url.to_string(), "protocol" => PROTOCOL, "kind" => self.kind.to_string() @@ -184,7 +184,7 @@ impl InternalEvent for WebSocketReceiveError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_receive_error", "error_type" => error_type::CONNECTION_FAILED, @@ -209,7 +209,7 @@ impl InternalEvent for WebSocketSendError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "protocol" => PROTOCOL, "error_code" => "websocket_send_error", "error_type" => error_type::CONNECTION_FAILED, diff --git a/src/internal_events/websocket_server.rs b/src/internal_events/websocket_server.rs index 0c543ad56eee0..dd7b1b8cd9f8b 100644 --- a/src/internal_events/websocket_server.rs +++ b/src/internal_events/websocket_server.rs @@ -1,7 +1,7 @@ use std::{error::Error, fmt::Debug}; use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; use vector_lib::{counter, gauge}; #[derive(Debug, NamedInternalEvent)] @@ -18,8 +18,8 @@ impl InternalEvent for WebSocketListenerConnectionEstablished { self.client_count ) ); - counter!(MetricName::ConnectionEstablishedTotal, &self.extra_tags).increment(1); - gauge!(MetricName::ActiveClients, &self.extra_tags).set(self.client_count as f64); + counter!(CounterName::ConnectionEstablishedTotal, &self.extra_tags).increment(1); + gauge!(CounterName::ActiveClients, &self.extra_tags).set(self.client_count as f64); } } @@ -49,7 +49,7 @@ impl InternalEvent for WebSocketListenerConnectionFailedError { ]); // Tags required by `component_errors_total` are dynamically added above. // ## skip check-validity-events ## - counter!(MetricName::ComponentErrorsTotal, &all_tags).increment(1); + counter!(CounterName::ComponentErrorsTotal, &all_tags).increment(1); } } @@ -67,8 +67,8 @@ impl InternalEvent for WebSocketListenerConnectionShutdown { self.client_count ) ); - counter!(MetricName::ConnectionShutdownTotal, &self.extra_tags).increment(1); - gauge!(MetricName::ActiveClients, &self.extra_tags).set(self.client_count as f64); + counter!(CounterName::ConnectionShutdownTotal, &self.extra_tags).increment(1); + gauge!(CounterName::ActiveClients, &self.extra_tags).set(self.client_count as f64); } } @@ -87,7 +87,7 @@ impl InternalEvent for WebSocketListenerSendError { stage = error_stage::SENDING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "ws_server_connection_error", "error_type" => error_type::WRITER_FAILED, "stage" => error_stage::SENDING, @@ -104,8 +104,8 @@ pub struct WebSocketListenerMessageSent { impl InternalEvent for WebSocketListenerMessageSent { fn emit(self) { - counter!(MetricName::WebsocketMessagesSentTotal, &self.extra_tags).increment(1); - counter!(MetricName::WebsocketBytesSentTotal, &self.extra_tags) + counter!(CounterName::WebsocketMessagesSentTotal, &self.extra_tags).increment(1); + counter!(CounterName::WebsocketBytesSentTotal, &self.extra_tags) .increment(self.message_size as u64); } } diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index 4d5c87b83bcc7..17fc8c1e958a2 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -11,7 +11,7 @@ use std::{ }; use arr_macro::arr; -use vector_common::{counter, gauge, internal_event::MetricName}; +use vector_common::{counter, gauge, internal_event::CounterName}; use rand_distr::num_traits::ToPrimitive; use self::allocator::Tracer; @@ -144,26 +144,26 @@ pub fn init_allocation_tracing() { let group_info = group.lock().unwrap(); if allocations_diff > 0 { counter!( - MetricName::ComponentAllocatedBytesTotal, "component_kind" => group_info.component_kind.clone(), + CounterName::ComponentAllocatedBytesTotal, "component_kind" => group_info.component_kind.clone(), "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone()).increment(allocations_diff); } if deallocations_diff > 0 { counter!( - MetricName::ComponentDeallocatedBytesTotal, "component_kind" => group_info.component_kind.clone(), + CounterName::ComponentDeallocatedBytesTotal, "component_kind" => group_info.component_kind.clone(), "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone()).increment(deallocations_diff); } if mem_used_diff > 0 { gauge!( - MetricName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), + CounterName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone(), "component_kind" => group_info.component_kind.clone()) .increment(mem_used_diff.to_f64().expect("failed to convert mem_used from int to float")); } if mem_used_diff < 0 { gauge!( - MetricName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), + CounterName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone(), "component_kind" => group_info.component_kind.clone()) .decrement(-mem_used_diff.to_f64().expect("failed to convert mem_used from int to float")); diff --git a/src/topology/builder.rs b/src/topology/builder.rs index fed8740646eb3..fc82cede25f01 100644 --- a/src/topology/builder.rs +++ b/src/topology/builder.rs @@ -8,7 +8,7 @@ use std::{ use futures::{FutureExt, StreamExt, TryStreamExt, stream::FuturesOrdered}; use futures_util::stream::FuturesUnordered; -use vector_lib::{gauge, internal_event::MetricName}; +use vector_lib::{gauge, internal_event::CounterName}; use stream_cancel::{StreamExt as StreamCancelExt, Trigger, Tripwire}; use tokio::{ select, @@ -627,7 +627,7 @@ impl<'a> Builder<'a> { let utilization_sender = self .utilization_registry - .add_component(key.clone(), gauge!(MetricName::Utilization)); + .add_component(key.clone(), gauge!(CounterName::Utilization)); let component_key = key.clone(); let sink = async move { debug!("Sink starting."); @@ -747,7 +747,7 @@ impl<'a> Builder<'a> { let sender = self .utilization_registry - .add_component(node.key.clone(), gauge!(MetricName::Utilization)); + .add_component(node.key.clone(), gauge!(CounterName::Utilization)); let runner = Runner::new( t, input_rx, @@ -803,7 +803,7 @@ impl<'a> Builder<'a> { let sender = self .utilization_registry - .add_component(key.clone(), gauge!(MetricName::Utilization)); + .add_component(key.clone(), gauge!(CounterName::Utilization)); let output_sender = sender.clone(); let input_rx = Utilization::new(sender, key.clone(), input_rx.into_stream()); From e1a304722b175ad19dacb09a9340e51a262286d9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 10:47:00 -0400 Subject: [PATCH 10/17] Merge imports --- lib/vector-core/src/latency.rs | 5 ++++- src/internal_events/adaptive_concurrency.rs | 3 +-- src/internal_events/aggregate.rs | 6 ++++-- src/internal_events/amqp.rs | 6 ++++-- src/internal_events/apache_metrics.rs | 3 +-- src/internal_events/api.rs | 6 ++++-- src/internal_events/aws.rs | 6 ++++-- src/internal_events/aws_ec2_metadata.rs | 6 ++++-- src/internal_events/aws_ecs_metrics.rs | 3 +-- src/internal_events/aws_kinesis_firehose.rs | 6 ++++-- src/internal_events/aws_sqs.rs | 6 ++++-- src/internal_events/conditions.rs | 6 ++++-- src/internal_events/datadog_agent.rs | 6 ++++-- src/internal_events/dedupe.rs | 6 ++++-- src/internal_events/demo_logs.rs | 3 +-- src/internal_events/dnstap.rs | 6 ++++-- src/internal_events/docker_logs.rs | 5 ++--- src/internal_events/encoding_transcode.rs | 6 ++++-- src/internal_events/eventstoredb_metrics.rs | 6 ++++-- src/internal_events/exec.rs | 5 ++--- src/internal_events/file.rs | 5 ++--- src/internal_events/file_descriptor.rs | 6 ++++-- src/internal_events/fluent.rs | 6 ++++-- src/internal_events/gcp_pubsub.rs | 6 ++++-- src/internal_events/grpc.rs | 7 ++++--- src/internal_events/heartbeat.rs | 6 ++++-- src/internal_events/host_metrics.rs | 6 ++++-- src/internal_events/http.rs | 3 +-- src/internal_events/http_client.rs | 7 ++++--- src/internal_events/http_client_source.rs | 3 +-- src/internal_events/journald.rs | 2 +- src/internal_events/kafka.rs | 3 +-- src/internal_events/kubernetes_logs.rs | 3 +-- src/internal_events/log_to_metric.rs | 8 +++++--- src/internal_events/logplex.rs | 6 ++++-- src/internal_events/loki.rs | 4 ++-- src/internal_events/mongodb_metrics.rs | 3 +-- src/internal_events/mqtt.rs | 6 ++++-- src/internal_events/nginx_metrics.rs | 3 +-- src/internal_events/open.rs | 6 ++++-- src/internal_events/parser.rs | 8 +++++--- src/internal_events/postgresql_metrics.rs | 6 ++++-- src/internal_events/process.rs | 6 ++++-- src/internal_events/prometheus.rs | 10 ++++++---- src/internal_events/redis.rs | 6 ++++-- src/internal_events/reduce.rs | 6 ++++-- src/internal_events/sample.rs | 6 ++++-- src/internal_events/sematext_metrics.rs | 8 +++++--- src/internal_events/socket.rs | 5 ++--- src/internal_events/splunk_hec.rs | 15 ++++++++++----- src/internal_events/tag_cardinality_limit.rs | 6 ++++-- src/internal_events/tcp.rs | 6 ++++-- src/internal_events/template.rs | 8 +++++--- src/internal_events/throttle.rs | 6 ++++-- src/internal_events/udp.rs | 8 +++++--- src/internal_events/websocket.rs | 7 ++++--- src/internal_events/websocket_server.rs | 7 ++++--- src/internal_events/windows.rs | 6 ++++-- src/internal_events/windows_event_log.rs | 3 +-- src/internal_telemetry/allocations/mod.rs | 2 +- src/topology/builder.rs | 2 +- 61 files changed, 205 insertions(+), 136 deletions(-) diff --git a/lib/vector-core/src/latency.rs b/lib/vector-core/src/latency.rs index 61d51d3a44a81..b25ca73427749 100644 --- a/lib/vector-core/src/latency.rs +++ b/lib/vector-core/src/latency.rs @@ -2,7 +2,10 @@ use std::time::Instant; use metrics::Histogram; use vector_common::stats::EwmaGauge; -use vector_common::{gauge, histogram, internal_event::{GaugeName, HistogramName}}; +use vector_common::{ + gauge, histogram, + internal_event::{GaugeName, HistogramName}, +}; use crate::event::EventArray; diff --git a/src/internal_events/adaptive_concurrency.rs b/src/internal_events/adaptive_concurrency.rs index c60bbb678072c..d144083c7c194 100644 --- a/src/internal_events/adaptive_concurrency.rs +++ b/src/internal_events/adaptive_concurrency.rs @@ -1,8 +1,7 @@ use std::time::Duration; use metrics::Histogram; -use vector_lib::histogram; -use vector_lib::internal_event::CounterName; +use vector_lib::{histogram, internal_event::CounterName}; #[derive(Clone, Copy)] pub struct AdaptiveConcurrencyLimitData { diff --git a/src/internal_events/aggregate.rs b/src/internal_events/aggregate.rs index b47aee35f0546..96f48f5de013c 100644 --- a/src/internal_events/aggregate.rs +++ b/src/internal_events/aggregate.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent}, +}; #[derive(Debug, NamedInternalEvent)] pub struct AggregateEventRecorded; diff --git a/src/internal_events/amqp.rs b/src/internal_events/amqp.rs index 54d7251026f5b..e7864acc44e98 100644 --- a/src/internal_events/amqp.rs +++ b/src/internal_events/amqp.rs @@ -1,7 +1,9 @@ #[cfg(feature = "sources-amqp")] pub mod source { - use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; - use vector_lib::{NamedInternalEvent, counter}; + use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, + }; #[derive(Debug, NamedInternalEvent)] pub struct AmqpBytesReceived { diff --git a/src/internal_events/apache_metrics.rs b/src/internal_events/apache_metrics.rs index 24d82925c0ec0..544dda88ba5a6 100644 --- a/src/internal_events/apache_metrics.rs +++ b/src/internal_events/apache_metrics.rs @@ -1,6 +1,5 @@ -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/api.rs b/src/internal_events/api.rs index 10b349ddc50d8..b9196989471c8 100644 --- a/src/internal_events/api.rs +++ b/src/internal_events/api.rs @@ -1,7 +1,9 @@ use std::net::SocketAddr; -use vector_lib::internal_event::{CounterName, InternalEvent}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent}, +}; #[derive(Debug, NamedInternalEvent)] pub struct ApiStarted { diff --git a/src/internal_events/aws.rs b/src/internal_events/aws.rs index 67c931f088510..d4c91776d7d55 100644 --- a/src/internal_events/aws.rs +++ b/src/internal_events/aws.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent}, +}; #[derive(NamedInternalEvent)] pub struct AwsBytesSent { diff --git a/src/internal_events/aws_ec2_metadata.rs b/src/internal_events/aws_ec2_metadata.rs index 296e4fd7d7dc4..c59364c75348c 100644 --- a/src/internal_events/aws_ec2_metadata.rs +++ b/src/internal_events/aws_ec2_metadata.rs @@ -1,5 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct AwsEc2MetadataRefreshSuccessful; diff --git a/src/internal_events/aws_ecs_metrics.rs b/src/internal_events/aws_ecs_metrics.rs index dcb774d439504..59127134e2666 100644 --- a/src/internal_events/aws_ecs_metrics.rs +++ b/src/internal_events/aws_ecs_metrics.rs @@ -1,8 +1,7 @@ use std::borrow::Cow; -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/aws_kinesis_firehose.rs b/src/internal_events/aws_kinesis_firehose.rs index ed7b12e37f67a..58f976839debd 100644 --- a/src/internal_events/aws_kinesis_firehose.rs +++ b/src/internal_events/aws_kinesis_firehose.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; use super::prelude::{http_error_code, io_error_code}; use crate::sources::aws_kinesis_firehose::Compression; diff --git a/src/internal_events/aws_sqs.rs b/src/internal_events/aws_sqs.rs index b828072f287cf..8a746feb3cedc 100644 --- a/src/internal_events/aws_sqs.rs +++ b/src/internal_events/aws_sqs.rs @@ -4,8 +4,10 @@ pub use s3::*; use vector_lib::counter; #[cfg(any(feature = "sources-aws_s3", feature = "sources-aws_sqs"))] -use vector_lib::internal_event::{CounterName, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, internal_event::InternalEvent}; +use vector_lib::{ + NamedInternalEvent, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[cfg(feature = "sources-aws_s3")] mod s3 { diff --git a/src/internal_events/conditions.rs b/src/internal_events/conditions.rs index 80985af88e45b..e89f63b6a9c54 100644 --- a/src/internal_events/conditions.rs +++ b/src/internal_events/conditions.rs @@ -1,5 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, Copy, Clone, NamedInternalEvent)] pub struct VrlConditionExecutionError<'a> { diff --git a/src/internal_events/datadog_agent.rs b/src/internal_events/datadog_agent.rs index c1e6dff0d53c2..84a4a8535c0c7 100644 --- a/src/internal_events/datadog_agent.rs +++ b/src/internal_events/datadog_agent.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct DatadogAgentJsonParseError<'a> { diff --git a/src/internal_events/dedupe.rs b/src/internal_events/dedupe.rs index eb7511578cdd7..a1c36a3c4fa2b 100644 --- a/src/internal_events/dedupe.rs +++ b/src/internal_events/dedupe.rs @@ -1,5 +1,7 @@ -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; +use vector_lib::{ + NamedInternalEvent, + internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}, +}; #[derive(Debug, NamedInternalEvent)] pub struct DedupeEventsDropped { diff --git a/src/internal_events/demo_logs.rs b/src/internal_events/demo_logs.rs index 406a9856fe6e9..3958f41421ca7 100644 --- a/src/internal_events/demo_logs.rs +++ b/src/internal_events/demo_logs.rs @@ -1,5 +1,4 @@ -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::InternalEvent; +use vector_lib::{NamedInternalEvent, internal_event::InternalEvent}; #[derive(Debug, NamedInternalEvent)] pub struct DemoLogsEventProcessed; diff --git a/src/internal_events/dnstap.rs b/src/internal_events/dnstap.rs index 4a6ce045e88ab..1ef67ee3001e0 100644 --- a/src/internal_events/dnstap.rs +++ b/src/internal_events/dnstap.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub(crate) struct DnstapParseError { diff --git a/src/internal_events/docker_logs.rs b/src/internal_events/docker_logs.rs index 7e21ad9b59ba0..fe24d41b6350b 100644 --- a/src/internal_events/docker_logs.rs +++ b/src/internal_events/docker_logs.rs @@ -1,9 +1,8 @@ use bollard::errors::Error; use chrono::ParseError; -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, - internal_event::{InternalEvent, CounterName, error_stage, error_type}, + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/encoding_transcode.rs b/src/internal_events/encoding_transcode.rs index 85f0ac7cf8130..ec6280f1c703d 100644 --- a/src/internal_events/encoding_transcode.rs +++ b/src/internal_events/encoding_transcode.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent}, +}; #[derive(Debug, NamedInternalEvent)] pub struct DecoderBomRemoval { diff --git a/src/internal_events/eventstoredb_metrics.rs b/src/internal_events/eventstoredb_metrics.rs index 13ff76336a864..c7db7fad354a5 100644 --- a/src/internal_events/eventstoredb_metrics.rs +++ b/src/internal_events/eventstoredb_metrics.rs @@ -1,5 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct EventStoreDbMetricsHttpError { diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index bbe5493f216fb..9b25f2e8e03da 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -2,13 +2,12 @@ use std::time::Duration; use tokio::time::error::Elapsed; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, histogram, internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; -use vector_lib::{counter, histogram}; use super::prelude::io_error_code; diff --git a/src/internal_events/file.rs b/src/internal_events/file.rs index 5426f3c1eeda9..29136a19e5702 100644 --- a/src/internal_events/file.rs +++ b/src/internal_events/file.rs @@ -5,11 +5,11 @@ use std::borrow::Cow; use vector_lib::{ NamedInternalEvent, configurable::configurable_component, + counter, gauge, internal_event::{ ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, }; -use vector_lib::{counter, gauge}; #[cfg(any(feature = "sources-file", feature = "sources-kubernetes_logs"))] pub use self::source::*; @@ -110,9 +110,8 @@ mod source { use std::{io::Error, path::Path, time::Duration}; use bytes::BytesMut; - use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, emit, + NamedInternalEvent, counter, emit, file_source_common::internal_events::FileSourceInternalEvents, internal_event::{ ComponentEventsDropped, CounterName, INTENTIONAL, error_stage, error_type, diff --git a/src/internal_events/file_descriptor.rs b/src/internal_events/file_descriptor.rs index 5a56ddbd267b1..8db4e7895729e 100644 --- a/src/internal_events/file_descriptor.rs +++ b/src/internal_events/file_descriptor.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct FileDescriptorReadError { diff --git a/src/internal_events/fluent.rs b/src/internal_events/fluent.rs index 7ba62f9d6c50f..f47b927d5cbe2 100644 --- a/src/internal_events/fluent.rs +++ b/src/internal_events/fluent.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; use crate::sources::fluent::DecodeError; diff --git a/src/internal_events/gcp_pubsub.rs b/src/internal_events/gcp_pubsub.rs index 95901fbac9540..752546cfa7d09 100644 --- a/src/internal_events/gcp_pubsub.rs +++ b/src/internal_events/gcp_pubsub.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(NamedInternalEvent)] pub struct GcpPubsubConnectError { diff --git a/src/internal_events/grpc.rs b/src/internal_events/grpc.rs index 1d66aa6a4f4e1..61acdfd16b7f9 100644 --- a/src/internal_events/grpc.rs +++ b/src/internal_events/grpc.rs @@ -2,9 +2,10 @@ use std::time::Duration; use http::response::Response; use tonic::Code; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{counter, histogram}; +use vector_lib::{ + NamedInternalEvent, counter, histogram, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; const GRPC_STATUS_LABEL: &str = "grpc_status"; diff --git a/src/internal_events/heartbeat.rs b/src/internal_events/heartbeat.rs index 25ead99b8fdd2..89a6b702f88d7 100644 --- a/src/internal_events/heartbeat.rs +++ b/src/internal_events/heartbeat.rs @@ -1,7 +1,9 @@ use std::time::Instant; -use vector_lib::internal_event::{CounterName, InternalEvent}; -use vector_lib::{NamedInternalEvent, gauge}; +use vector_lib::{ + NamedInternalEvent, gauge, + internal_event::{CounterName, InternalEvent}, +}; use crate::built_info; diff --git a/src/internal_events/host_metrics.rs b/src/internal_events/host_metrics.rs index bfb432aabc43b..7662ca5e808a4 100644 --- a/src/internal_events/host_metrics.rs +++ b/src/internal_events/host_metrics.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct HostMetricsScrapeError { diff --git a/src/internal_events/http.rs b/src/internal_events/http.rs index 1a3fc59a2aa4c..f045c850caa84 100644 --- a/src/internal_events/http.rs +++ b/src/internal_events/http.rs @@ -2,11 +2,10 @@ use std::{error::Error, time::Duration}; use http::Response; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, histogram, internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; -use vector_lib::{counter, histogram}; const HTTP_STATUS_LABEL: &str = "status"; diff --git a/src/internal_events/http_client.rs b/src/internal_events/http_client.rs index 2d23d9a5a8129..ecad0b8a04e31 100644 --- a/src/internal_events/http_client.rs +++ b/src/internal_events/http_client.rs @@ -5,9 +5,10 @@ use http::{ header::{self, HeaderMap, HeaderValue}, }; use hyper::{Error, body::HttpBody}; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{counter, histogram}; +use vector_lib::{ + NamedInternalEvent, counter, histogram, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct AboutToSendHttpRequest<'a, T> { diff --git a/src/internal_events/http_client_source.rs b/src/internal_events/http_client_source.rs index c0dace6fdae4f..0ba52d722dfee 100644 --- a/src/internal_events/http_client_source.rs +++ b/src/internal_events/http_client_source.rs @@ -1,8 +1,7 @@ #![allow(dead_code)] // TODO requires optional feature compilation -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/journald.rs b/src/internal_events/journald.rs index 7e1ad8ce34561..02f6300cb6905 100644 --- a/src/internal_events/journald.rs +++ b/src/internal_events/journald.rs @@ -1,7 +1,7 @@ -use vector_lib::counter; use vector_lib::{ NamedInternalEvent, codecs::decoding::BoxedFramingError, + counter, internal_event::{CounterName, InternalEvent, error_stage, error_type}, }; diff --git a/src/internal_events/kafka.rs b/src/internal_events/kafka.rs index 9da9ddab7167d..222891c45afad 100644 --- a/src/internal_events/kafka.rs +++ b/src/internal_events/kafka.rs @@ -1,11 +1,10 @@ #![allow(dead_code)] // TODO requires optional feature compilation use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, gauge, internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; -use vector_lib::{counter, gauge}; use vrl::path::OwnedTargetPath; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/kubernetes_logs.rs b/src/internal_events/kubernetes_logs.rs index 79920ddfae182..15b4ca4e61ee0 100644 --- a/src/internal_events/kubernetes_logs.rs +++ b/src/internal_events/kubernetes_logs.rs @@ -1,6 +1,5 @@ -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, internal_event::{ ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, error_type, diff --git a/src/internal_events/log_to_metric.rs b/src/internal_events/log_to_metric.rs index e766d3b15eea1..e8e3da5b898b7 100644 --- a/src/internal_events/log_to_metric.rs +++ b/src/internal_events/log_to_metric.rs @@ -1,8 +1,10 @@ use std::num::ParseFloatError; -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + }, }; #[derive(NamedInternalEvent)] diff --git a/src/internal_events/logplex.rs b/src/internal_events/logplex.rs index e47c62284051f..4a45df6349b65 100644 --- a/src/internal_events/logplex.rs +++ b/src/internal_events/logplex.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; use super::prelude::io_error_code; diff --git a/src/internal_events/loki.rs b/src/internal_events/loki.rs index a110f5c95d8c4..3a5935e1a372a 100644 --- a/src/internal_events/loki.rs +++ b/src/internal_events/loki.rs @@ -1,7 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; use vector_lib::internal_event::{ - ComponentEventsDropped, INTENTIONAL, InternalEvent, CounterName, error_stage, error_type, + ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent, error_stage, error_type, }; +use vector_lib::{NamedInternalEvent, counter}; #[derive(Debug, NamedInternalEvent)] pub struct LokiEventUnlabeledError; diff --git a/src/internal_events/mongodb_metrics.rs b/src/internal_events/mongodb_metrics.rs index 0e314937ab831..b0023085f025f 100644 --- a/src/internal_events/mongodb_metrics.rs +++ b/src/internal_events/mongodb_metrics.rs @@ -1,7 +1,6 @@ use mongodb::{bson, error::Error as MongoError}; -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/mqtt.rs b/src/internal_events/mqtt.rs index b82b321f1de70..8d416c4c748ee 100644 --- a/src/internal_events/mqtt.rs +++ b/src/internal_events/mqtt.rs @@ -1,8 +1,10 @@ use std::fmt::Debug; use rumqttc::ConnectionError; -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct MqttConnectionError { diff --git a/src/internal_events/nginx_metrics.rs b/src/internal_events/nginx_metrics.rs index 6b58cff4a741a..82cd7ea3878b7 100644 --- a/src/internal_events/nginx_metrics.rs +++ b/src/internal_events/nginx_metrics.rs @@ -1,6 +1,5 @@ -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, internal_event::{CounterName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; diff --git a/src/internal_events/open.rs b/src/internal_events/open.rs index eb55bbda12700..402fbe769bfdd 100644 --- a/src/internal_events/open.rs +++ b/src/internal_events/open.rs @@ -6,8 +6,10 @@ use std::{ }, }; -use vector_lib::internal_event::{CounterName, InternalEvent}; -use vector_lib::{NamedInternalEvent, gauge}; +use vector_lib::{ + NamedInternalEvent, gauge, + internal_event::{CounterName, InternalEvent}, +}; #[derive(Debug, NamedInternalEvent)] pub struct ConnectionOpen { diff --git a/src/internal_events/parser.rs b/src/internal_events/parser.rs index ec538894b7e51..2610ae5458958 100644 --- a/src/internal_events/parser.rs +++ b/src/internal_events/parser.rs @@ -2,9 +2,11 @@ use std::borrow::Cow; -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + }, }; fn truncate_string_at(s: &str, maxlen: usize) -> Cow<'_, str> { diff --git a/src/internal_events/postgresql_metrics.rs b/src/internal_events/postgresql_metrics.rs index fddaedf3a698b..62fa4d18a722d 100644 --- a/src/internal_events/postgresql_metrics.rs +++ b/src/internal_events/postgresql_metrics.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct PostgresqlMetricsCollectError<'a> { diff --git a/src/internal_events/process.rs b/src/internal_events/process.rs index f0c40c210ce1b..19701c6feaca8 100644 --- a/src/internal_events/process.rs +++ b/src/internal_events/process.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; use crate::{built_info, config}; diff --git a/src/internal_events/prometheus.rs b/src/internal_events/prometheus.rs index 9bcf6d878e819..3ddd3c555f728 100644 --- a/src/internal_events/prometheus.rs +++ b/src/internal_events/prometheus.rs @@ -3,12 +3,14 @@ #[cfg(feature = "sources-prometheus-scrape")] use std::borrow::Cow; -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, -}; #[cfg(feature = "sources-prometheus-scrape")] use vector_lib::prometheus::parser::ParserError; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + }, +}; #[cfg(feature = "sources-prometheus-scrape")] #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/redis.rs b/src/internal_events/redis.rs index e7bafbd72f241..87b9bc6d7b2f8 100644 --- a/src/internal_events/redis.rs +++ b/src/internal_events/redis.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct RedisReceiveEventError { diff --git a/src/internal_events/reduce.rs b/src/internal_events/reduce.rs index 8dbb06bc652c0..0962c6332a439 100644 --- a/src/internal_events/reduce.rs +++ b/src/internal_events/reduce.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{CounterName, InternalEvent, error_stage, error_type}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; use vrl::{path::PathParseError, value::KeyString}; #[derive(Debug, NamedInternalEvent)] diff --git a/src/internal_events/sample.rs b/src/internal_events/sample.rs index 3722f9530b668..825175dc42555 100644 --- a/src/internal_events/sample.rs +++ b/src/internal_events/sample.rs @@ -1,5 +1,7 @@ -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; +use vector_lib::{ + NamedInternalEvent, + internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}, +}; #[derive(Debug, NamedInternalEvent)] pub struct SampleEventDiscarded; diff --git a/src/internal_events/sematext_metrics.rs b/src/internal_events/sematext_metrics.rs index bfbd7b09e340f..cb03742a5d3d1 100644 --- a/src/internal_events/sematext_metrics.rs +++ b/src/internal_events/sematext_metrics.rs @@ -1,6 +1,8 @@ -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + }, }; use crate::event::metric::Metric; diff --git a/src/internal_events/socket.rs b/src/internal_events/socket.rs index 92e821fec32f8..241a7b8919119 100644 --- a/src/internal_events/socket.rs +++ b/src/internal_events/socket.rs @@ -1,13 +1,12 @@ use std::net::Ipv4Addr; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, histogram, internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; -use vector_lib::{counter, histogram}; #[derive(Debug, Clone, Copy, Eq, PartialEq)] #[allow(dead_code)] // some features only use some variants diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index 4f57078812a8c..c8a7127711267 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -8,9 +8,12 @@ pub use self::source::*; #[cfg(feature = "sinks-splunk_hec")] mod sink { use serde_json::Error; - use vector_lib::{NamedInternalEvent, counter, gauge}; - use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, + use vector_lib::{ + NamedInternalEvent, counter, gauge, + internal_event::{ + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, + error_type, + }, }; use crate::{ @@ -196,8 +199,10 @@ mod sink { #[cfg(feature = "sources-splunk_hec")] mod source { - use vector_lib::{NamedInternalEvent, counter}; - use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; + use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, + }; use crate::sources::splunk_hec::ApiError; diff --git a/src/internal_events/tag_cardinality_limit.rs b/src/internal_events/tag_cardinality_limit.rs index 30951ed642fd9..9906f5c320f6b 100644 --- a/src/internal_events/tag_cardinality_limit.rs +++ b/src/internal_events/tag_cardinality_limit.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent}, +}; #[derive(NamedInternalEvent)] pub struct TagCardinalityLimitRejectingEvent<'a> { diff --git a/src/internal_events/tcp.rs b/src/internal_events/tcp.rs index 6c754b8c0817b..1ec0cfb6322e5 100644 --- a/src/internal_events/tcp.rs +++ b/src/internal_events/tcp.rs @@ -1,7 +1,9 @@ use std::net::SocketAddr; -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; use crate::{internal_events::SocketOutgoingConnectionError, tls::TlsError}; diff --git a/src/internal_events/template.rs b/src/internal_events/template.rs index 6f04fb2628dd2..db43081e2a22a 100644 --- a/src/internal_events/template.rs +++ b/src/internal_events/template.rs @@ -1,6 +1,8 @@ -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + }, }; #[derive(NamedInternalEvent)] diff --git a/src/internal_events/throttle.rs b/src/internal_events/throttle.rs index a04db768ca762..3757bbae40535 100644 --- a/src/internal_events/throttle.rs +++ b/src/internal_events/throttle.rs @@ -1,5 +1,7 @@ -use vector_lib::internal_event::{ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent}; -use vector_lib::{NamedInternalEvent, counter}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ComponentEventsDropped, CounterName, INTENTIONAL, InternalEvent}, +}; #[derive(Debug, NamedInternalEvent)] pub(crate) struct ThrottleEventDiscarded { diff --git a/src/internal_events/udp.rs b/src/internal_events/udp.rs index d4ae75d38e4b5..31e5f5c6533a4 100644 --- a/src/internal_events/udp.rs +++ b/src/internal_events/udp.rs @@ -1,6 +1,8 @@ -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{ - ComponentEventsDropped, InternalEvent, CounterName, UNINTENTIONAL, error_stage, error_type, +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{ + ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + }, }; use crate::internal_events::SocketOutgoingConnectionError; diff --git a/src/internal_events/websocket.rs b/src/internal_events/websocket.rs index bb32a990ea069..6f8f5671977d1 100644 --- a/src/internal_events/websocket.rs +++ b/src/internal_events/websocket.rs @@ -10,9 +10,10 @@ use vector_common::{ internal_event::{error_stage, error_type}, json_size::JsonSize, }; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{CounterName, InternalEvent}; -use vector_lib::{counter, histogram}; +use vector_lib::{ + NamedInternalEvent, counter, histogram, + internal_event::{CounterName, InternalEvent}, +}; pub const PROTOCOL: &str = "websocket"; diff --git a/src/internal_events/websocket_server.rs b/src/internal_events/websocket_server.rs index dd7b1b8cd9f8b..a3ebf74ddecd5 100644 --- a/src/internal_events/websocket_server.rs +++ b/src/internal_events/websocket_server.rs @@ -1,8 +1,9 @@ use std::{error::Error, fmt::Debug}; -use vector_lib::NamedInternalEvent; -use vector_lib::internal_event::{InternalEvent, CounterName, error_stage, error_type}; -use vector_lib::{counter, gauge}; +use vector_lib::{ + NamedInternalEvent, counter, gauge, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct WebSocketListenerConnectionEstablished { diff --git a/src/internal_events/windows.rs b/src/internal_events/windows.rs index b660a350810ba..53eea1acaa1e0 100644 --- a/src/internal_events/windows.rs +++ b/src/internal_events/windows.rs @@ -1,5 +1,7 @@ -use vector_lib::{NamedInternalEvent, counter}; -use vector_lib::internal_event::{InternalEvent, MetricName, error_stage, error_type}; +use vector_lib::{ + NamedInternalEvent, counter, + internal_event::{InternalEvent, MetricName, error_stage, error_type}, +}; #[derive(Debug, NamedInternalEvent)] pub struct WindowsServiceStart<'a> { diff --git a/src/internal_events/windows_event_log.rs b/src/internal_events/windows_event_log.rs index 1e406d8ef3c30..dde3a75d62752 100644 --- a/src/internal_events/windows_event_log.rs +++ b/src/internal_events/windows_event_log.rs @@ -1,7 +1,6 @@ use tracing::error; -use vector_lib::counter; use vector_lib::{ - NamedInternalEvent, + NamedInternalEvent, counter, internal_event::{InternalEvent, MetricName, error_stage, error_type}, }; diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index 17fc8c1e958a2..3923a08f4a170 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -11,8 +11,8 @@ use std::{ }; use arr_macro::arr; -use vector_common::{counter, gauge, internal_event::CounterName}; use rand_distr::num_traits::ToPrimitive; +use vector_common::{counter, gauge, internal_event::CounterName}; use self::allocator::Tracer; pub(crate) use self::allocator::{ diff --git a/src/topology/builder.rs b/src/topology/builder.rs index fc82cede25f01..5cafb36513411 100644 --- a/src/topology/builder.rs +++ b/src/topology/builder.rs @@ -8,7 +8,6 @@ use std::{ use futures::{FutureExt, StreamExt, TryStreamExt, stream::FuturesOrdered}; use futures_util::stream::FuturesUnordered; -use vector_lib::{gauge, internal_event::CounterName}; use stream_cancel::{StreamExt as StreamCancelExt, Trigger, Tripwire}; use tokio::{ select, @@ -31,6 +30,7 @@ use vector_lib::{ source_sender::{CHUNK_SIZE, SourceSenderItem}, transform::update_runtime_schema_definition, }; +use vector_lib::{gauge, internal_event::CounterName}; use vector_vrl_metrics::MetricsStorage; use super::{ From 4bc4e3463754e99cb0c754ffb1683eac0642ac46 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 11:09:58 -0400 Subject: [PATCH 11/17] Finish MetricName separation --- .../src/internal_event/metric_name.rs | 136 +++++++++--------- .../memory/internal_events.rs | 6 +- src/internal_events/adaptive_concurrency.rs | 16 +-- src/internal_events/aws_sqs.rs | 6 +- src/internal_events/common.rs | 4 +- src/internal_events/exec.rs | 4 +- src/internal_events/file.rs | 4 +- src/internal_events/grpc.rs | 4 +- src/internal_events/heartbeat.rs | 6 +- src/internal_events/http.rs | 6 +- src/internal_events/http_client.rs | 10 +- src/internal_events/kafka.rs | 8 +- src/internal_events/lua.rs | 4 +- src/internal_events/open.rs | 6 +- src/internal_events/socket.rs | 6 +- src/internal_events/splunk_hec.rs | 6 +- src/internal_events/websocket.rs | 4 +- src/internal_events/websocket_server.rs | 6 +- src/internal_telemetry/allocations/mod.rs | 6 +- src/topology/builder.rs | 8 +- 20 files changed, 128 insertions(+), 128 deletions(-) diff --git a/lib/vector-common/src/internal_event/metric_name.rs b/lib/vector-common/src/internal_event/metric_name.rs index c7e4d4f0d064c..21314695a13bf 100644 --- a/lib/vector-common/src/internal_event/metric_name.rs +++ b/lib/vector-common/src/internal_event/metric_name.rs @@ -22,27 +22,14 @@ pub enum CounterName { BufferDiscardedBytesTotal, BufferErrorsTotal, // Internal events from src/internal_events/ - ActiveClients, - ActiveEndpoints, - AdaptiveConcurrencyAveragedRtt, - AdaptiveConcurrencyBackPressure, - AdaptiveConcurrencyInFlight, - AdaptiveConcurrencyLimit, - AdaptiveConcurrencyObservedRtt, - AdaptiveConcurrencyPastRttMean, - AdaptiveConcurrencyReachedLimit, AggregateEventsRecordedTotal, AggregateFailedUpdates, AggregateFlushesTotal, ApiStartedTotal, - BuildInfo, CheckpointsTotal, ChecksumErrorsTotal, CollectCompletedTotal, - CollectDurationSeconds, CommandExecutedTotal, - CommandExecutionDurationSeconds, - ComponentReceivedBytes, ConnectionEstablishedTotal, ConnectionSendErrorsTotal, ConnectionShutdownTotal, @@ -60,39 +47,27 @@ pub enum CounterName { FilesDeletedTotal, FilesResumedTotal, FilesUnwatchedTotal, - GrpcServerHandlerDurationSeconds, GrpcServerMessagesReceivedTotal, GrpcServerMessagesSentTotal, - HttpClientErrorRttSeconds, HttpClientErrorsTotal, HttpClientRequestsSentTotal, - HttpClientResponseRttSeconds, HttpClientResponsesTotal, - HttpClientRttSeconds, - HttpServerHandlerDurationSeconds, HttpServerRequestsReceivedTotal, HttpServerResponsesSentTotal, KafkaConsumedMessagesBytesTotal, KafkaConsumedMessagesTotal, - KafkaConsumerLag, KafkaProducedMessagesBytesTotal, KafkaProducedMessagesTotal, - KafkaQueueMessages, - KafkaQueueMessagesBytes, KafkaRequestsBytesTotal, KafkaRequestsTotal, KafkaResponsesBytesTotal, KafkaResponsesTotal, - LuaMemoryUsedBytes, MetadataRefreshFailedTotal, MetadataRefreshSuccessfulTotal, - OpenConnections, - OpenFiles, ParseErrorsTotal, QuitTotal, ReloadedTotal, RewrittenTimestampEventsTotal, - SplunkPendingAcks, SqsMessageDeferSucceededTotal, SqsMessageDeleteSucceededTotal, SqsMessageProcessingSucceededTotal, @@ -102,7 +77,6 @@ pub enum CounterName { StartedTotal, StoppedTotal, TagValueLimitExceededTotal, - UptimeSeconds, ValueLimitReachedTotal, WebsocketBytesSentTotal, WebsocketMessagesSentTotal, @@ -115,19 +89,13 @@ pub enum CounterName { K8sEventNodeAnnotationFailuresTotal, K8sFormatPickerEdgeCasesTotal, K8sDockerFormatParseFailuresTotal, - S3ObjectProcessingSucceededDurationSeconds, - S3ObjectProcessingFailedDurationSeconds, SqsS3EventRecordIgnoredTotal, ComponentAllocatedBytesTotal, ComponentDeallocatedBytesTotal, - ComponentAllocatedBytes, - Utilization, - MemoryEnrichmentTableByteSize, MemoryEnrichmentTableFailedInsertions, MemoryEnrichmentTableFailedReads, MemoryEnrichmentTableFlushesTotal, MemoryEnrichmentTableInsertionsTotal, - MemoryEnrichmentTableObjectsCount, MemoryEnrichmentTableReadsTotal, MemoryEnrichmentTableTtlExpirations, } @@ -136,11 +104,28 @@ pub enum CounterName { #[strum(serialize_all = "snake_case")] pub enum HistogramName { ComponentReceivedEventsCount, + ComponentReceivedBytes, BufferSendDurationSeconds, ComponentLatencySeconds, SourceLagTimeSeconds, SourceSendLatencySeconds, SourceSendBatchLatencySeconds, + AdaptiveConcurrencyAveragedRtt, + AdaptiveConcurrencyBackPressure, + AdaptiveConcurrencyInFlight, + AdaptiveConcurrencyLimit, + AdaptiveConcurrencyObservedRtt, + AdaptiveConcurrencyPastRttMean, + AdaptiveConcurrencyReachedLimit, + S3ObjectProcessingSucceededDurationSeconds, + S3ObjectProcessingFailedDurationSeconds, + CollectDurationSeconds, + CommandExecutionDurationSeconds, + GrpcServerHandlerDurationSeconds, + HttpServerHandlerDurationSeconds, + HttpClientRttSeconds, + HttpClientResponseRttSeconds, + HttpClientErrorRttSeconds, } impl HistogramName { @@ -148,11 +133,32 @@ impl HistogramName { pub const fn as_str(self) -> &'static str { match self { Self::ComponentReceivedEventsCount => "component_received_events_count", + Self::ComponentReceivedBytes => "component_received_bytes", Self::BufferSendDurationSeconds => "buffer_send_duration_seconds", Self::ComponentLatencySeconds => "component_latency_seconds", Self::SourceLagTimeSeconds => "source_lag_time_seconds", Self::SourceSendLatencySeconds => "source_send_latency_seconds", Self::SourceSendBatchLatencySeconds => "source_send_batch_latency_seconds", + Self::AdaptiveConcurrencyAveragedRtt => "adaptive_concurrency_averaged_rtt", + Self::AdaptiveConcurrencyBackPressure => "adaptive_concurrency_back_pressure", + Self::AdaptiveConcurrencyInFlight => "adaptive_concurrency_in_flight", + Self::AdaptiveConcurrencyLimit => "adaptive_concurrency_limit", + Self::AdaptiveConcurrencyObservedRtt => "adaptive_concurrency_observed_rtt", + Self::AdaptiveConcurrencyPastRttMean => "adaptive_concurrency_past_rtt_mean", + Self::AdaptiveConcurrencyReachedLimit => "adaptive_concurrency_reached_limit", + Self::S3ObjectProcessingSucceededDurationSeconds => { + "s3_object_processing_succeeded_duration_seconds" + } + Self::S3ObjectProcessingFailedDurationSeconds => { + "s3_object_processing_failed_duration_seconds" + } + Self::CollectDurationSeconds => "collect_duration_seconds", + Self::CommandExecutionDurationSeconds => "command_execution_duration_seconds", + Self::GrpcServerHandlerDurationSeconds => "grpc_server_handler_duration_seconds", + Self::HttpServerHandlerDurationSeconds => "http_server_handler_duration_seconds", + Self::HttpClientRttSeconds => "http_client_rtt_seconds", + Self::HttpClientResponseRttSeconds => "http_client_response_rtt_seconds", + Self::HttpClientErrorRttSeconds => "http_client_error_rtt_seconds", } } } @@ -169,6 +175,21 @@ pub enum GaugeName { BufferSizeEvents, BufferSizeBytes, BufferByteSize, + Utilization, + ComponentAllocatedBytes, + OpenFiles, + UptimeSeconds, + BuildInfo, + KafkaQueueMessages, + KafkaQueueMessagesBytes, + KafkaConsumerLag, + LuaMemoryUsedBytes, + OpenConnections, + ActiveEndpoints, + SplunkPendingAcks, + ActiveClients, + MemoryEnrichmentTableObjectsCount, + MemoryEnrichmentTableByteSize, } impl GaugeName { @@ -184,6 +205,21 @@ impl GaugeName { Self::BufferSizeEvents => "buffer_size_events", Self::BufferSizeBytes => "buffer_size_bytes", Self::BufferByteSize => "buffer_byte_size", + Self::Utilization => "utilization", + Self::ComponentAllocatedBytes => "component_allocated_bytes", + Self::OpenFiles => "open_files", + Self::UptimeSeconds => "uptime_seconds", + Self::BuildInfo => "build_info", + Self::KafkaQueueMessages => "kafka_queue_messages", + Self::KafkaQueueMessagesBytes => "kafka_queue_messages_bytes", + Self::KafkaConsumerLag => "kafka_consumer_lag", + Self::LuaMemoryUsedBytes => "lua_memory_used_bytes", + Self::OpenConnections => "open_connections", + Self::ActiveEndpoints => "active_endpoints", + Self::SplunkPendingAcks => "splunk_pending_acks", + Self::ActiveClients => "active_clients", + Self::MemoryEnrichmentTableObjectsCount => "memory_enrichment_table_objects_count", + Self::MemoryEnrichmentTableByteSize => "memory_enrichment_table_byte_size", } } } @@ -210,27 +246,14 @@ impl CounterName { Self::BufferDiscardedEventsTotal => "buffer_discarded_events_total", Self::BufferDiscardedBytesTotal => "buffer_discarded_bytes_total", Self::BufferErrorsTotal => "buffer_errors_total", - Self::ActiveClients => "active_clients", - Self::ActiveEndpoints => "active_endpoints", - Self::AdaptiveConcurrencyAveragedRtt => "adaptive_concurrency_averaged_rtt", - Self::AdaptiveConcurrencyBackPressure => "adaptive_concurrency_back_pressure", - Self::AdaptiveConcurrencyInFlight => "adaptive_concurrency_in_flight", - Self::AdaptiveConcurrencyLimit => "adaptive_concurrency_limit", - Self::AdaptiveConcurrencyObservedRtt => "adaptive_concurrency_observed_rtt", - Self::AdaptiveConcurrencyPastRttMean => "adaptive_concurrency_past_rtt_mean", - Self::AdaptiveConcurrencyReachedLimit => "adaptive_concurrency_reached_limit", Self::AggregateEventsRecordedTotal => "aggregate_events_recorded_total", Self::AggregateFailedUpdates => "aggregate_failed_updates", Self::AggregateFlushesTotal => "aggregate_flushes_total", Self::ApiStartedTotal => "api_started_total", - Self::BuildInfo => "build_info", Self::CheckpointsTotal => "checkpoints_total", Self::ChecksumErrorsTotal => "checksum_errors_total", Self::CollectCompletedTotal => "collect_completed_total", - Self::CollectDurationSeconds => "collect_duration_seconds", Self::CommandExecutedTotal => "command_executed_total", - Self::CommandExecutionDurationSeconds => "command_execution_duration_seconds", - Self::ComponentReceivedBytes => "component_received_bytes", Self::ConnectionEstablishedTotal => "connection_established_total", Self::ConnectionSendErrorsTotal => "connection_send_errors_total", Self::ConnectionShutdownTotal => "connection_shutdown_total", @@ -252,39 +275,27 @@ impl CounterName { Self::FilesDeletedTotal => "files_deleted_total", Self::FilesResumedTotal => "files_resumed_total", Self::FilesUnwatchedTotal => "files_unwatched_total", - Self::GrpcServerHandlerDurationSeconds => "grpc_server_handler_duration_seconds", Self::GrpcServerMessagesReceivedTotal => "grpc_server_messages_received_total", Self::GrpcServerMessagesSentTotal => "grpc_server_messages_sent_total", - Self::HttpClientErrorRttSeconds => "http_client_error_rtt_seconds", Self::HttpClientErrorsTotal => "http_client_errors_total", Self::HttpClientRequestsSentTotal => "http_client_requests_sent_total", - Self::HttpClientResponseRttSeconds => "http_client_response_rtt_seconds", Self::HttpClientResponsesTotal => "http_client_responses_total", - Self::HttpClientRttSeconds => "http_client_rtt_seconds", - Self::HttpServerHandlerDurationSeconds => "http_server_handler_duration_seconds", Self::HttpServerRequestsReceivedTotal => "http_server_requests_received_total", Self::HttpServerResponsesSentTotal => "http_server_responses_sent_total", Self::KafkaConsumedMessagesBytesTotal => "kafka_consumed_messages_bytes_total", Self::KafkaConsumedMessagesTotal => "kafka_consumed_messages_total", - Self::KafkaConsumerLag => "kafka_consumer_lag", Self::KafkaProducedMessagesBytesTotal => "kafka_produced_messages_bytes_total", Self::KafkaProducedMessagesTotal => "kafka_produced_messages_total", - Self::KafkaQueueMessages => "kafka_queue_messages", - Self::KafkaQueueMessagesBytes => "kafka_queue_messages_bytes", Self::KafkaRequestsBytesTotal => "kafka_requests_bytes_total", Self::KafkaRequestsTotal => "kafka_requests_total", Self::KafkaResponsesBytesTotal => "kafka_responses_bytes_total", Self::KafkaResponsesTotal => "kafka_responses_total", - Self::LuaMemoryUsedBytes => "lua_memory_used_bytes", Self::MetadataRefreshFailedTotal => "metadata_refresh_failed_total", Self::MetadataRefreshSuccessfulTotal => "metadata_refresh_successful_total", - Self::OpenConnections => "open_connections", - Self::OpenFiles => "open_files", Self::ParseErrorsTotal => "parse_errors_total", Self::QuitTotal => "quit_total", Self::ReloadedTotal => "reloaded_total", Self::RewrittenTimestampEventsTotal => "rewritten_timestamp_events_total", - Self::SplunkPendingAcks => "splunk_pending_acks", Self::SqsMessageDeferSucceededTotal => "sqs_message_defer_succeeded_total", Self::SqsMessageDeleteSucceededTotal => "sqs_message_delete_succeeded_total", Self::SqsMessageProcessingSucceededTotal => "sqs_message_processing_succeeded_total", @@ -294,7 +305,6 @@ impl CounterName { Self::StartedTotal => "started_total", Self::StoppedTotal => "stopped_total", Self::TagValueLimitExceededTotal => "tag_value_limit_exceeded_total", - Self::UptimeSeconds => "uptime_seconds", Self::ValueLimitReachedTotal => "value_limit_reached_total", Self::WebsocketBytesSentTotal => "websocket_bytes_sent_total", Self::WebsocketMessagesSentTotal => "websocket_messages_sent_total", @@ -309,18 +319,9 @@ impl CounterName { Self::K8sEventNodeAnnotationFailuresTotal => "k8s_event_node_annotation_failures_total", Self::K8sFormatPickerEdgeCasesTotal => "k8s_format_picker_edge_cases_total", Self::K8sDockerFormatParseFailuresTotal => "k8s_docker_format_parse_failures_total", - Self::S3ObjectProcessingSucceededDurationSeconds => { - "s3_object_processing_succeeded_duration_seconds" - } - Self::S3ObjectProcessingFailedDurationSeconds => { - "s3_object_processing_failed_duration_seconds" - } Self::SqsS3EventRecordIgnoredTotal => "sqs_s3_event_record_ignored_total", Self::ComponentAllocatedBytesTotal => "component_allocated_bytes_total", Self::ComponentDeallocatedBytesTotal => "component_deallocated_bytes_total", - Self::ComponentAllocatedBytes => "component_allocated_bytes", - Self::Utilization => "utilization", - Self::MemoryEnrichmentTableByteSize => "memory_enrichment_table_byte_size", Self::MemoryEnrichmentTableFailedInsertions => { "memory_enrichment_table_failed_insertions" } @@ -329,7 +330,6 @@ impl CounterName { Self::MemoryEnrichmentTableInsertionsTotal => { "memory_enrichment_table_insertions_total" } - Self::MemoryEnrichmentTableObjectsCount => "memory_enrichment_table_objects_count", Self::MemoryEnrichmentTableReadsTotal => "memory_enrichment_table_reads_total", Self::MemoryEnrichmentTableTtlExpirations => "memory_enrichment_table_ttl_expirations", } diff --git a/src/enrichment_tables/memory/internal_events.rs b/src/enrichment_tables/memory/internal_events.rs index b6553443fbc48..dfd7b8d6f4c78 100644 --- a/src/enrichment_tables/memory/internal_events.rs +++ b/src/enrichment_tables/memory/internal_events.rs @@ -2,7 +2,7 @@ use vector_lib::{ NamedInternalEvent, configurable::configurable_component, counter, gauge, - internal_event::{CounterName, InternalEvent}, + internal_event::{CounterName, GaugeName, InternalEvent}, }; /// Configuration of internal metrics for enrichment memory table. @@ -67,8 +67,8 @@ pub(crate) struct MemoryEnrichmentTableFlushed { impl InternalEvent for MemoryEnrichmentTableFlushed { fn emit(self) { counter!(CounterName::MemoryEnrichmentTableFlushesTotal,).increment(1); - gauge!(CounterName::MemoryEnrichmentTableObjectsCount,).set(self.new_objects_count as f64); - gauge!(CounterName::MemoryEnrichmentTableByteSize,).set(self.new_byte_size as f64); + gauge!(GaugeName::MemoryEnrichmentTableObjectsCount,).set(self.new_objects_count as f64); + gauge!(GaugeName::MemoryEnrichmentTableByteSize,).set(self.new_byte_size as f64); } } diff --git a/src/internal_events/adaptive_concurrency.rs b/src/internal_events/adaptive_concurrency.rs index d144083c7c194..b43ec8452e20b 100644 --- a/src/internal_events/adaptive_concurrency.rs +++ b/src/internal_events/adaptive_concurrency.rs @@ -1,7 +1,7 @@ use std::time::Duration; use metrics::Histogram; -use vector_lib::{histogram, internal_event::CounterName}; +use vector_lib::{histogram, internal_event::HistogramName}; #[derive(Clone, Copy)] pub struct AdaptiveConcurrencyLimitData { @@ -18,10 +18,10 @@ registered_event! { // These are histograms, as they may have a number of different // values over each reporting interval, and each of those values // is valuable for diagnosis. - limit: Histogram = histogram!(CounterName::AdaptiveConcurrencyLimit), - reached_limit: Histogram = histogram!(CounterName::AdaptiveConcurrencyReachedLimit), - back_pressure: Histogram = histogram!(CounterName::AdaptiveConcurrencyBackPressure), - past_rtt_mean: Histogram = histogram!(CounterName::AdaptiveConcurrencyPastRttMean), + limit: Histogram = histogram!(HistogramName::AdaptiveConcurrencyLimit), + reached_limit: Histogram = histogram!(HistogramName::AdaptiveConcurrencyReachedLimit), + back_pressure: Histogram = histogram!(HistogramName::AdaptiveConcurrencyBackPressure), + past_rtt_mean: Histogram = histogram!(HistogramName::AdaptiveConcurrencyPastRttMean), } fn emit(&self, data: AdaptiveConcurrencyLimitData) { @@ -37,7 +37,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyInFlight => { - in_flight: Histogram = histogram!(CounterName::AdaptiveConcurrencyInFlight), + in_flight: Histogram = histogram!(HistogramName::AdaptiveConcurrencyInFlight), } fn emit(&self, in_flight: u64) { @@ -47,7 +47,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyObservedRtt => { - observed_rtt: Histogram = histogram!(CounterName::AdaptiveConcurrencyObservedRtt), + observed_rtt: Histogram = histogram!(HistogramName::AdaptiveConcurrencyObservedRtt), } fn emit(&self, rtt: Duration) { @@ -57,7 +57,7 @@ registered_event! { registered_event! { AdaptiveConcurrencyAveragedRtt => { - averaged_rtt: Histogram = histogram!(CounterName::AdaptiveConcurrencyAveragedRtt), + averaged_rtt: Histogram = histogram!(HistogramName::AdaptiveConcurrencyAveragedRtt), } fn emit(&self, rtt: Duration) { diff --git a/src/internal_events/aws_sqs.rs b/src/internal_events/aws_sqs.rs index 8a746feb3cedc..51e8b78d23941 100644 --- a/src/internal_events/aws_sqs.rs +++ b/src/internal_events/aws_sqs.rs @@ -6,7 +6,7 @@ use vector_lib::counter; #[cfg(any(feature = "sources-aws_s3", feature = "sources-aws_sqs"))] use vector_lib::{ NamedInternalEvent, - internal_event::{CounterName, InternalEvent, error_stage, error_type}, + internal_event::{CounterName, HistogramName, InternalEvent, error_stage, error_type}, }; #[cfg(feature = "sources-aws_s3")] @@ -36,7 +36,7 @@ mod s3 { duration_ms = %self.duration.as_millis(), ); histogram!( - CounterName::S3ObjectProcessingSucceededDurationSeconds, + HistogramName::S3ObjectProcessingSucceededDurationSeconds, "bucket" => self.bucket.to_owned(), ) .record(self.duration); @@ -57,7 +57,7 @@ mod s3 { duration_ms = %self.duration.as_millis(), ); histogram!( - CounterName::S3ObjectProcessingFailedDurationSeconds, + HistogramName::S3ObjectProcessingFailedDurationSeconds, "bucket" => self.bucket.to_owned(), ) .record(self.duration); diff --git a/src/internal_events/common.rs b/src/internal_events/common.rs index 94095a7de24ea..0b2ab8a4f004e 100644 --- a/src/internal_events/common.rs +++ b/src/internal_events/common.rs @@ -3,7 +3,7 @@ use std::time::Instant; use vector_lib::NamedInternalEvent; pub use vector_lib::internal_event::EventsReceived; use vector_lib::internal_event::{ - ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use vector_lib::{counter, histogram}; @@ -118,7 +118,7 @@ impl InternalEvent for CollectionCompleted { fn emit(self) { debug!(message = "Collection completed."); counter!(CounterName::CollectCompletedTotal).increment(1); - histogram!(CounterName::CollectDurationSeconds).record(self.end - self.start); + histogram!(HistogramName::CollectDurationSeconds).record(self.end - self.start); } } diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index 9b25f2e8e03da..ab0c569131b82 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -4,7 +4,7 @@ use tokio::time::error::Elapsed; use vector_lib::{ NamedInternalEvent, counter, histogram, internal_event::{ - ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; @@ -126,7 +126,7 @@ impl InternalEvent for ExecCommandExecuted<'_> { .increment(1); histogram!( - CounterName::CommandExecutionDurationSeconds, + HistogramName::CommandExecutionDurationSeconds, "exit_status" => exit_status, "command" => self.command.to_owned(), ) diff --git a/src/internal_events/file.rs b/src/internal_events/file.rs index 29136a19e5702..0bb330e336505 100644 --- a/src/internal_events/file.rs +++ b/src/internal_events/file.rs @@ -7,7 +7,7 @@ use vector_lib::{ configurable::configurable_component, counter, gauge, internal_event::{ - ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, }; @@ -34,7 +34,7 @@ pub struct FileOpen { impl InternalEvent for FileOpen { fn emit(self) { - gauge!(CounterName::OpenFiles).set(self.count as f64); + gauge!(GaugeName::OpenFiles).set(self.count as f64); } } diff --git a/src/internal_events/grpc.rs b/src/internal_events/grpc.rs index 61acdfd16b7f9..66da41e10b797 100644 --- a/src/internal_events/grpc.rs +++ b/src/internal_events/grpc.rs @@ -4,7 +4,7 @@ use http::response::Response; use tonic::Code; use vector_lib::{ NamedInternalEvent, counter, histogram, - internal_event::{CounterName, InternalEvent, error_stage, error_type}, + internal_event::{CounterName, HistogramName, InternalEvent, error_stage, error_type}, }; const GRPC_STATUS_LABEL: &str = "grpc_status"; @@ -36,7 +36,7 @@ impl InternalEvent for GrpcServerResponseSent<'_, B> { let labels = &[(GRPC_STATUS_LABEL, grpc_code)]; counter!(CounterName::GrpcServerMessagesSentTotal, labels).increment(1); - histogram!(CounterName::GrpcServerHandlerDurationSeconds, labels).record(self.latency); + histogram!(HistogramName::GrpcServerHandlerDurationSeconds, labels).record(self.latency); } } diff --git a/src/internal_events/heartbeat.rs b/src/internal_events/heartbeat.rs index 89a6b702f88d7..16191669e7317 100644 --- a/src/internal_events/heartbeat.rs +++ b/src/internal_events/heartbeat.rs @@ -2,7 +2,7 @@ use std::time::Instant; use vector_lib::{ NamedInternalEvent, gauge, - internal_event::{CounterName, InternalEvent}, + internal_event::{GaugeName, InternalEvent}, }; use crate::built_info; @@ -15,9 +15,9 @@ pub struct Heartbeat { impl InternalEvent for Heartbeat { fn emit(self) { trace!(target: "vector", message = "Beep."); - gauge!(CounterName::UptimeSeconds).set(self.since.elapsed().as_secs() as f64); + gauge!(GaugeName::UptimeSeconds).set(self.since.elapsed().as_secs() as f64); gauge!( - CounterName::BuildInfo, + GaugeName::BuildInfo, "debug" => built_info::DEBUG, "version" => built_info::PKG_VERSION, "rust_version" => built_info::RUST_VERSION, diff --git a/src/internal_events/http.rs b/src/internal_events/http.rs index f045c850caa84..4aad267d7683b 100644 --- a/src/internal_events/http.rs +++ b/src/internal_events/http.rs @@ -3,7 +3,7 @@ use std::{error::Error, time::Duration}; use http::Response; use vector_lib::{ NamedInternalEvent, counter, histogram, - internal_event::{CounterName, InternalEvent, error_stage, error_type}, + internal_event::{CounterName, HistogramName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; @@ -32,7 +32,7 @@ impl InternalEvent for HttpServerResponseSent<'_, B> { self.response.status().as_u16().to_string(), )]; counter!(CounterName::HttpServerResponsesSentTotal, labels).increment(1); - histogram!(CounterName::HttpServerHandlerDurationSeconds, labels).record(self.latency); + histogram!(HistogramName::HttpServerHandlerDurationSeconds, labels).record(self.latency); } } @@ -78,7 +78,7 @@ impl InternalEvent for HttpEventsReceived<'_> { protocol = %self.protocol, ); - histogram!(CounterName::ComponentReceivedEventsCount).record(self.count as f64); + histogram!(HistogramName::ComponentReceivedEventsCount).record(self.count as f64); counter!( CounterName::ComponentReceivedEventsTotal, "http_path" => self.http_path.to_string(), diff --git a/src/internal_events/http_client.rs b/src/internal_events/http_client.rs index ecad0b8a04e31..346192dfca141 100644 --- a/src/internal_events/http_client.rs +++ b/src/internal_events/http_client.rs @@ -7,7 +7,7 @@ use http::{ use hyper::{Error, body::HttpBody}; use vector_lib::{ NamedInternalEvent, counter, histogram, - internal_event::{CounterName, InternalEvent, error_stage, error_type}, + internal_event::{CounterName, HistogramName, InternalEvent, error_stage, error_type}, }; #[derive(Debug, NamedInternalEvent)] @@ -65,9 +65,9 @@ impl InternalEvent for GotHttpResponse<'_, T> { "status" => self.response.status().as_u16().to_string(), ) .increment(1); - histogram!(CounterName::HttpClientRttSeconds).record(self.roundtrip); + histogram!(HistogramName::HttpClientRttSeconds).record(self.roundtrip); histogram!( - CounterName::HttpClientResponseRttSeconds, + HistogramName::HttpClientResponseRttSeconds, "status" => self.response.status().as_u16().to_string(), ) .record(self.roundtrip); @@ -90,8 +90,8 @@ impl InternalEvent for GotHttpWarning<'_> { ); counter!(CounterName::HttpClientErrorsTotal, "error_kind" => self.error.to_string()) .increment(1); - histogram!(CounterName::HttpClientRttSeconds).record(self.roundtrip); - histogram!(CounterName::HttpClientErrorRttSeconds, "error_kind" => self.error.to_string()) + histogram!(HistogramName::HttpClientRttSeconds).record(self.roundtrip); + histogram!(HistogramName::HttpClientErrorRttSeconds, "error_kind" => self.error.to_string()) .record(self.roundtrip); } } diff --git a/src/internal_events/kafka.rs b/src/internal_events/kafka.rs index 222891c45afad..1cbd2ba3ce8cb 100644 --- a/src/internal_events/kafka.rs +++ b/src/internal_events/kafka.rs @@ -2,7 +2,7 @@ use vector_lib::{ NamedInternalEvent, counter, gauge, - internal_event::{CounterName, InternalEvent, error_stage, error_type}, + internal_event::{CounterName, GaugeName, InternalEvent, error_stage, error_type}, json_size::JsonSize, }; use vrl::path::OwnedTargetPath; @@ -122,8 +122,8 @@ pub struct KafkaStatisticsReceived<'a> { impl InternalEvent for KafkaStatisticsReceived<'_> { fn emit(self) { - gauge!(CounterName::KafkaQueueMessages).set(self.statistics.msg_cnt as f64); - gauge!(CounterName::KafkaQueueMessagesBytes).set(self.statistics.msg_size as f64); + gauge!(GaugeName::KafkaQueueMessages).set(self.statistics.msg_cnt as f64); + gauge!(GaugeName::KafkaQueueMessagesBytes).set(self.statistics.msg_size as f64); counter!(CounterName::KafkaRequestsTotal).absolute(self.statistics.tx as u64); counter!(CounterName::KafkaRequestsBytesTotal).absolute(self.statistics.tx_bytes as u64); counter!(CounterName::KafkaResponsesTotal).absolute(self.statistics.rx as u64); @@ -139,7 +139,7 @@ impl InternalEvent for KafkaStatisticsReceived<'_> { for (topic_id, topic) in &self.statistics.topics { for (partition_id, partition) in &topic.partitions { gauge!( - CounterName::KafkaConsumerLag, + GaugeName::KafkaConsumerLag, "topic_id" => topic_id.clone(), "partition_id" => partition_id.to_string(), ) diff --git a/src/internal_events/lua.rs b/src/internal_events/lua.rs index a2052272be76f..bc96251af2eab 100644 --- a/src/internal_events/lua.rs +++ b/src/internal_events/lua.rs @@ -1,6 +1,6 @@ use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ - ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use vector_lib::{counter, gauge}; @@ -13,7 +13,7 @@ pub struct LuaGcTriggered { impl InternalEvent for LuaGcTriggered { fn emit(self) { - gauge!(CounterName::LuaMemoryUsedBytes).set(self.used_memory as f64); + gauge!(GaugeName::LuaMemoryUsedBytes).set(self.used_memory as f64); } } diff --git a/src/internal_events/open.rs b/src/internal_events/open.rs index 402fbe769bfdd..58e9c9d40b3f8 100644 --- a/src/internal_events/open.rs +++ b/src/internal_events/open.rs @@ -8,7 +8,7 @@ use std::{ use vector_lib::{ NamedInternalEvent, gauge, - internal_event::{CounterName, InternalEvent}, + internal_event::{GaugeName, InternalEvent}, }; #[derive(Debug, NamedInternalEvent)] @@ -18,7 +18,7 @@ pub struct ConnectionOpen { impl InternalEvent for ConnectionOpen { fn emit(self) { - gauge!(CounterName::OpenConnections).set(self.count as f64); + gauge!(GaugeName::OpenConnections).set(self.count as f64); } } @@ -29,7 +29,7 @@ pub struct EndpointsActive { impl InternalEvent for EndpointsActive { fn emit(self) { - gauge!(CounterName::ActiveEndpoints).set(self.count as f64); + gauge!(GaugeName::ActiveEndpoints).set(self.count as f64); } } diff --git a/src/internal_events/socket.rs b/src/internal_events/socket.rs index 241a7b8919119..37069068c367e 100644 --- a/src/internal_events/socket.rs +++ b/src/internal_events/socket.rs @@ -3,7 +3,7 @@ use std::net::Ipv4Addr; use vector_lib::{ NamedInternalEvent, counter, histogram, internal_event::{ - ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, json_size::JsonSize, }; @@ -45,7 +45,7 @@ impl InternalEvent for SocketBytesReceived { "protocol" => protocol, ) .increment(self.byte_size as u64); - histogram!(CounterName::ComponentReceivedBytes).record(self.byte_size as f64); + histogram!(HistogramName::ComponentReceivedBytes).record(self.byte_size as f64); } } @@ -69,7 +69,7 @@ impl InternalEvent for SocketEventsReceived { .increment(self.count as u64); counter!(CounterName::ComponentReceivedEventBytesTotal, "mode" => mode) .increment(self.byte_size.get() as u64); - histogram!(CounterName::ComponentReceivedBytes, "mode" => mode) + histogram!(HistogramName::ComponentReceivedBytes, "mode" => mode) .record(self.byte_size.get() as f64); } } diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index c8a7127711267..0d2ecfad63877 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -11,7 +11,7 @@ mod sink { use vector_lib::{ NamedInternalEvent, counter, gauge, internal_event::{ - ComponentEventsDropped, CounterName, InternalEvent, UNINTENTIONAL, error_stage, + ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, error_type, }, }; @@ -157,7 +157,7 @@ mod sink { impl InternalEvent for SplunkIndexerAcknowledgementAckAdded { fn emit(self) { - gauge!(CounterName::SplunkPendingAcks).increment(1.0); + gauge!(GaugeName::SplunkPendingAcks).increment(1.0); } } @@ -168,7 +168,7 @@ mod sink { impl InternalEvent for SplunkIndexerAcknowledgementAcksRemoved { fn emit(self) { - gauge!(CounterName::SplunkPendingAcks).decrement(self.count); + gauge!(GaugeName::SplunkPendingAcks).decrement(self.count); } } diff --git a/src/internal_events/websocket.rs b/src/internal_events/websocket.rs index 6f8f5671977d1..b842407ee0313 100644 --- a/src/internal_events/websocket.rs +++ b/src/internal_events/websocket.rs @@ -12,7 +12,7 @@ use vector_common::{ }; use vector_lib::{ NamedInternalEvent, counter, histogram, - internal_event::{CounterName, InternalEvent}, + internal_event::{CounterName, HistogramName, InternalEvent}, }; pub const PROTOCOL: &str = "websocket"; @@ -151,7 +151,7 @@ impl InternalEvent for WebSocketMessageReceived<'_> { kind = %self.kind ); - let histogram = histogram!(CounterName::ComponentReceivedEventsCount); + let histogram = histogram!(HistogramName::ComponentReceivedEventsCount); histogram.record(self.count as f64); let counter = counter!( CounterName::ComponentReceivedEventsTotal, diff --git a/src/internal_events/websocket_server.rs b/src/internal_events/websocket_server.rs index a3ebf74ddecd5..bdace6b079da5 100644 --- a/src/internal_events/websocket_server.rs +++ b/src/internal_events/websocket_server.rs @@ -2,7 +2,7 @@ use std::{error::Error, fmt::Debug}; use vector_lib::{ NamedInternalEvent, counter, gauge, - internal_event::{CounterName, InternalEvent, error_stage, error_type}, + internal_event::{CounterName, GaugeName, InternalEvent, error_stage, error_type}, }; #[derive(Debug, NamedInternalEvent)] @@ -20,7 +20,7 @@ impl InternalEvent for WebSocketListenerConnectionEstablished { ) ); counter!(CounterName::ConnectionEstablishedTotal, &self.extra_tags).increment(1); - gauge!(CounterName::ActiveClients, &self.extra_tags).set(self.client_count as f64); + gauge!(GaugeName::ActiveClients, &self.extra_tags).set(self.client_count as f64); } } @@ -69,7 +69,7 @@ impl InternalEvent for WebSocketListenerConnectionShutdown { ) ); counter!(CounterName::ConnectionShutdownTotal, &self.extra_tags).increment(1); - gauge!(CounterName::ActiveClients, &self.extra_tags).set(self.client_count as f64); + gauge!(GaugeName::ActiveClients, &self.extra_tags).set(self.client_count as f64); } } diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index 3923a08f4a170..60741470c999e 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -12,7 +12,7 @@ use std::{ use arr_macro::arr; use rand_distr::num_traits::ToPrimitive; -use vector_common::{counter, gauge, internal_event::CounterName}; +use vector_common::{counter, gauge, internal_event::{CounterName, GaugeName}}; use self::allocator::Tracer; pub(crate) use self::allocator::{ @@ -156,14 +156,14 @@ pub fn init_allocation_tracing() { } if mem_used_diff > 0 { gauge!( - CounterName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), + GaugeName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone(), "component_kind" => group_info.component_kind.clone()) .increment(mem_used_diff.to_f64().expect("failed to convert mem_used from int to float")); } if mem_used_diff < 0 { gauge!( - CounterName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), + GaugeName::ComponentAllocatedBytes, "component_type" => group_info.component_type.clone(), "component_id" => group_info.component_id.clone(), "component_kind" => group_info.component_kind.clone()) .decrement(-mem_used_diff.to_f64().expect("failed to convert mem_used from int to float")); diff --git a/src/topology/builder.rs b/src/topology/builder.rs index 5cafb36513411..a25a99d337a26 100644 --- a/src/topology/builder.rs +++ b/src/topology/builder.rs @@ -30,7 +30,7 @@ use vector_lib::{ source_sender::{CHUNK_SIZE, SourceSenderItem}, transform::update_runtime_schema_definition, }; -use vector_lib::{gauge, internal_event::CounterName}; +use vector_lib::{gauge, internal_event::GaugeName}; use vector_vrl_metrics::MetricsStorage; use super::{ @@ -627,7 +627,7 @@ impl<'a> Builder<'a> { let utilization_sender = self .utilization_registry - .add_component(key.clone(), gauge!(CounterName::Utilization)); + .add_component(key.clone(), gauge!(GaugeName::Utilization)); let component_key = key.clone(); let sink = async move { debug!("Sink starting."); @@ -747,7 +747,7 @@ impl<'a> Builder<'a> { let sender = self .utilization_registry - .add_component(node.key.clone(), gauge!(CounterName::Utilization)); + .add_component(node.key.clone(), gauge!(GaugeName::Utilization)); let runner = Runner::new( t, input_rx, @@ -803,7 +803,7 @@ impl<'a> Builder<'a> { let sender = self .utilization_registry - .add_component(key.clone(), gauge!(CounterName::Utilization)); + .add_component(key.clone(), gauge!(GaugeName::Utilization)); let output_sender = sender.clone(); let input_rx = Utilization::new(sender, key.clone(), input_rx.into_stream()); From 2a883f0b61edbbaa88f965695b608ea309065351 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 11:26:10 -0400 Subject: [PATCH 12/17] chore: update check-events script to support typed metric name enums --- scripts/check-events | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/check-events b/scripts/check-events index 5d4411b601802..18a3c61b85418 100755 --- a/scripts/check-events +++ b/scripts/check-events @@ -78,11 +78,22 @@ class Event # Scan for counter names and tags def scan_metrics(block) + # Match string literal names: counter!("metric_name", ...) block.scan(/ (counter|gauge|histogram)!\((?:\n\s+)?"([^"]+)",?(.+?)\)[;\n]/ms) \ do |type, name, tags| tags = Hash[tags.scan(/"([^"]+)" => (.+?)(?:,|$)/)] add_metric(type, name, tags) end + # Match typed enum names: counter!(CounterName::VariantName, ...) + block.scan(/ (counter|gauge|histogram)!\((?:\n\s+)?\w+Name::(\w+),?(.+?)\)[;\n]/ms) \ + do |type, variant, tags| + # Convert CamelCase variant name to snake_case metric name + name = variant.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + .gsub(/([a-z\d])([A-Z])/, '\1_\2') + .downcase + tags = Hash[tags.scan(/"([^"]+)" => (.+?)(?:,|$)/)] + add_metric(type, name, tags) + end end # Scan the registered event macro block From 05ea8add77b8360998198b3d1b23b2cc52ea0d37 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 11:30:15 -0400 Subject: [PATCH 13/17] chore: fix stale MetricName doc references in macro wrappers --- lib/vector-common/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/vector-common/src/lib.rs b/lib/vector-common/src/lib.rs index 54617fbc5bdb2..9536eec83cf9e 100644 --- a/lib/vector-common/src/lib.rs +++ b/lib/vector-common/src/lib.rs @@ -66,10 +66,10 @@ pub mod trigger; #[macro_use] extern crate tracing; -/// Typed wrapper around `metrics::counter!` that only accepts [`internal_event::MetricName`]. +/// Typed wrapper around `metrics::counter!` that only accepts [`internal_event::CounterName`]. /// /// Prevents raw string literals from being used as metric names — all metric -/// names must go through the `MetricName` enum so they are discoverable and +/// names must go through the typed enums so they are discoverable and /// exposable via the API. #[macro_export] macro_rules! counter { @@ -89,7 +89,7 @@ macro_rules! counter { }}; } -/// Typed wrapper around `metrics::histogram!` that only accepts [`internal_event::MetricName`]. +/// Typed wrapper around `metrics::histogram!` that only accepts [`internal_event::HistogramName`]. #[macro_export] macro_rules! histogram { ($name:expr) => {{ @@ -108,7 +108,7 @@ macro_rules! histogram { }}; } -/// Typed wrapper around `metrics::gauge!` that only accepts [`internal_event::MetricName`]. +/// Typed wrapper around `metrics::gauge!` that only accepts [`internal_event::GaugeName`]. #[macro_export] macro_rules! gauge { ($name:expr) => {{ From 270433c1c71d8ca80162e73237b77ba9285488e3 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 11:30:33 -0400 Subject: [PATCH 14/17] chore: remove stale doc paragraph from counter! macro --- lib/vector-common/src/lib.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/vector-common/src/lib.rs b/lib/vector-common/src/lib.rs index 9536eec83cf9e..75849aac75884 100644 --- a/lib/vector-common/src/lib.rs +++ b/lib/vector-common/src/lib.rs @@ -67,10 +67,6 @@ pub mod trigger; extern crate tracing; /// Typed wrapper around `metrics::counter!` that only accepts [`internal_event::CounterName`]. -/// -/// Prevents raw string literals from being used as metric names — all metric -/// names must go through the typed enums so they are discoverable and -/// exposable via the API. #[macro_export] macro_rules! counter { ($name:expr) => {{ From 6bec4493a81b2b10cd202379f28022c50e81c35a Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 12:54:48 -0400 Subject: [PATCH 15/17] Fix clippy.toml --- clippy.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clippy.toml b/clippy.toml index 53065808f4629..4aaa1eb15b360 100644 --- a/clippy.toml +++ b/clippy.toml @@ -9,9 +9,9 @@ disallowed-methods = [ ] disallowed-macros = [ - { path = "metrics::counter", reason = "Use the `counter!` macro from `vector_common` with a `MetricName` variant instead of a raw string." }, - { path = "metrics::histogram", reason = "Use the `histogram!` macro from `vector_common` with a `MetricName` variant instead of a raw string." }, - { path = "metrics::gauge", reason = "Use the `gauge!` macro from `vector_common` with a `MetricName` variant instead of a raw string." }, + { path = "metrics::counter", reason = "Use the `counter!` macro from `vector_common` with a `CounterName` variant instead of a raw string." }, + { path = "metrics::histogram", reason = "Use the `histogram!` macro from `vector_common` with a `HistogramName` variant instead of a raw string." }, + { path = "metrics::gauge", reason = "Use the `gauge!` macro from `vector_common` with a `GaugeName` variant instead of a raw string." }, ] disallowed-types = [ From 148850b20e96dd951c61fdc9ce5765e259448502 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 14:22:59 -0400 Subject: [PATCH 16/17] Use first metric names instead of made up names to remove clippy::disallowed_macros --- Cargo.lock | 2 + Cargo.toml | 1 + benches/metrics_snapshot.rs | 7 +- .../src/internal_event/cached_event.rs | 7 +- lib/vector-core/Cargo.toml | 1 + lib/vector-core/src/metrics/mod.rs | 77 +++++++++++++------ src/internal_events/common.rs | 3 +- src/internal_events/exec.rs | 3 +- src/internal_events/file.rs | 3 +- src/internal_events/lua.rs | 3 +- src/internal_events/socket.rs | 3 +- src/internal_events/splunk_hec.rs | 4 +- src/internal_telemetry/allocations/mod.rs | 5 +- src/sources/internal_metrics.rs | 48 ++++++++---- src/utilization.rs | 8 +- 15 files changed, 118 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14687b0db7d70..2e217d2d24c4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12939,6 +12939,7 @@ dependencies = [ "sqlx", "stream-cancel", "strip-ansi-escapes", + "strum 0.28.0", "sysinfo", "syslog", "tempfile", @@ -13192,6 +13193,7 @@ dependencies = [ "smallvec", "snafu 0.9.0", "socket2 0.5.10", + "strum 0.28.0", "tokio", "tokio-openssl", "tokio-stream", diff --git a/Cargo.toml b/Cargo.toml index 904f540cd26a5..e9cf7da0f400b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -479,6 +479,7 @@ openssl-src = { version = "300", default-features = false, features = ["force-en [dev-dependencies] approx = "0.5.1" +strum.workspace = true assert_cmd = { version = "2.0.17", default-features = false } aws-smithy-runtime = { version = "1.8.3", default-features = false, features = ["tls-rustls"] } base64 = "0.22.1" diff --git a/benches/metrics_snapshot.rs b/benches/metrics_snapshot.rs index ae9e7603307f3..4df220256f7b9 100644 --- a/benches/metrics_snapshot.rs +++ b/benches/metrics_snapshot.rs @@ -1,4 +1,7 @@ use criterion::{BenchmarkId, Criterion, criterion_group}; +use strum::IntoEnumIterator; +use vector_lib::counter; +use vector_lib::internal_event::CounterName; fn benchmark(c: &mut Criterion) { let mut group = c.benchmark_group("metrics_snapshot"); @@ -17,14 +20,14 @@ fn benchmark(c: &mut Criterion) { group.finish(); } -#[allow(clippy::disallowed_macros)] fn prepare_metrics(cardinality: usize) -> &'static vector::metrics::Controller { vector::metrics::init_test(); let controller = vector::metrics::Controller::get().unwrap(); controller.reset(); + let name = CounterName::iter().next().unwrap(); for idx in 0..cardinality { - metrics::counter!("test", "idx" => idx.to_string()).increment(1); + counter!(name, "idx" => idx.to_string()).increment(1); } controller diff --git a/lib/vector-common/src/internal_event/cached_event.rs b/lib/vector-common/src/internal_event/cached_event.rs index 14c3c778ae13e..ec3d492998ab4 100644 --- a/lib/vector-common/src/internal_event/cached_event.rs +++ b/lib/vector-common/src/internal_event/cached_event.rs @@ -91,12 +91,13 @@ where #[cfg(test)] mod tests { #![allow(unreachable_pub)] - use metrics::{Counter, counter}; + use metrics::Counter; + use strum::IntoEnumIterator; use super::*; + use crate::internal_event::CounterName; #[test] - #[allow(clippy::disallowed_macros)] fn test_fixed_tag() { crate::registered_event!( TestEvent { @@ -104,7 +105,7 @@ mod tests { dynamic: String, } => { event: Counter = { - counter!("test_event_total", "fixed" => self.fixed, "dynamic" => self.dynamic) + crate::counter!(CounterName::iter().next().unwrap(), "fixed" => self.fixed, "dynamic" => self.dynamic) }, } diff --git a/lib/vector-core/Cargo.toml b/lib/vector-core/Cargo.toml index 5c3370ac1a526..edf7b43a4a74f 100644 --- a/lib/vector-core/Cargo.toml +++ b/lib/vector-core/Cargo.toml @@ -78,6 +78,7 @@ prost-build.workspace = true [dev-dependencies] base64 = "0.22.1" +strum.workspace = true chrono-tz.workspace = true criterion = { workspace = true, features = ["html_reports"] } env-test-util = "1.0.1" diff --git a/lib/vector-core/src/metrics/mod.rs b/lib/vector-core/src/metrics/mod.rs index edc70f1615a5b..ea4c040163c7f 100644 --- a/lib/vector-core/src/metrics/mod.rs +++ b/lib/vector-core/src/metrics/mod.rs @@ -202,7 +202,12 @@ impl Controller { #[cfg(test)] mod tests { - #![allow(clippy::disallowed_macros)] + use strum::IntoEnumIterator; + use vector_common::{ + counter, gauge, + internal_event::{CounterName, GaugeName}, + }; + use super::*; use crate::{ config::metrics_expiration::{ @@ -225,8 +230,9 @@ mod tests { let controller = Controller::get().unwrap(); controller.reset(); + let name = CounterName::iter().next().unwrap(); for idx in 0..cardinality { - metrics::counter!("test", "idx" => idx.to_string()).increment(1); + counter!(name, "idx" => idx.to_string()).increment(1); } let metrics = controller.capture_metrics(); @@ -254,11 +260,11 @@ mod tests { fn handles_registered_metrics() { let controller = init_metrics(); - let counter = metrics::counter!("test7"); + let counter = counter!(CounterName::iter().next().unwrap()); assert_eq!(controller.capture_metrics().len(), 3); counter.increment(1); assert_eq!(controller.capture_metrics().len(), 3); - let gauge = metrics::gauge!("test8"); + let gauge = gauge!(GaugeName::iter().next().unwrap()); assert_eq!(controller.capture_metrics().len(), 4); gauge.set(1.0); assert_eq!(controller.capture_metrics().len(), 4); @@ -271,12 +277,16 @@ mod tests { .set_expiry(Some(IDLE_TIMEOUT), Vec::new()) .unwrap(); - metrics::counter!("test2").increment(1); - metrics::counter!("test3").increment(2); + let mut names = CounterName::iter(); + let name_a = names.next().unwrap(); + let name_b = names.next().unwrap(); + + counter!(name_a).increment(1); + counter!(name_b).increment(2); assert_eq!(controller.capture_metrics().len(), 4); std::thread::sleep(Duration::from_secs_f64(IDLE_TIMEOUT * 2.0)); - metrics::counter!("test2").increment(3); + counter!(name_a).increment(3); assert_eq!(controller.capture_metrics().len(), 3); } @@ -287,12 +297,13 @@ mod tests { .set_expiry(Some(IDLE_TIMEOUT), Vec::new()) .unwrap(); - metrics::counter!("test4", "tag" => "value1").increment(1); - metrics::counter!("test4", "tag" => "value2").increment(2); + let name = CounterName::iter().next().unwrap(); + counter!(name, "tag" => "value1").increment(1); + counter!(name, "tag" => "value2").increment(2); assert_eq!(controller.capture_metrics().len(), 4); std::thread::sleep(Duration::from_secs_f64(IDLE_TIMEOUT * 2.0)); - metrics::counter!("test4", "tag" => "value1").increment(3); + counter!(name, "tag" => "value1").increment(3); assert_eq!(controller.capture_metrics().len(), 3); } @@ -303,8 +314,12 @@ mod tests { .set_expiry(Some(IDLE_TIMEOUT), Vec::new()) .unwrap(); - let a = metrics::counter!("test5"); - metrics::counter!("test6").increment(5); + let mut names = CounterName::iter(); + let name_a = names.next().unwrap(); + let name_b = names.next().unwrap(); + + let a = counter!(name_a); + counter!(name_b).increment(5); assert_eq!(controller.capture_metrics().len(), 4); a.increment(1); assert_eq!(controller.capture_metrics().len(), 4); @@ -317,7 +332,7 @@ mod tests { assert_eq!(metrics.len(), 3); let metric = metrics .into_iter() - .find(|metric| metric.name() == "test5") + .find(|metric| metric.name() == name_a.as_str()) .expect("Test metric is not present"); match metric.value() { MetricValue::Counter { value } => assert_eq!(*value, 2.0), @@ -328,12 +343,17 @@ mod tests { #[test] fn expires_metrics_per_set() { let controller = init_metrics(); + + let mut names = CounterName::iter(); + let name_a = names.next().unwrap(); + let name_b = names.next().unwrap(); + controller .set_expiry( None, vec![PerMetricSetExpiration { name: Some(MetricNameMatcherConfig::Exact { - value: "test3".to_string(), + value: name_b.as_str().to_string(), }), labels: None, expire_secs: IDLE_TIMEOUT, @@ -341,25 +361,32 @@ mod tests { ) .unwrap(); - metrics::counter!("test2").increment(1); - metrics::counter!("test3").increment(2); + counter!(name_a).increment(1); + counter!(name_b).increment(2); assert_eq!(controller.capture_metrics().len(), 4); std::thread::sleep(Duration::from_secs_f64(IDLE_TIMEOUT * 2.0)); - metrics::counter!("test2").increment(3); + counter!(name_a).increment(3); assert_eq!(controller.capture_metrics().len(), 3); } #[test] fn expires_metrics_multiple_different_sets() { let controller = init_metrics(); + + let mut names = CounterName::iter(); + let name_a = names.next().unwrap(); + let name_b = names.next().unwrap(); + let name_c = names.next().unwrap(); + let name_d = names.next().unwrap(); + controller .set_expiry( Some(IDLE_TIMEOUT * 3.0), vec![ PerMetricSetExpiration { name: Some(MetricNameMatcherConfig::Exact { - value: "test3".to_string(), + value: name_c.as_str().to_string(), }), labels: None, expire_secs: IDLE_TIMEOUT, @@ -378,22 +405,22 @@ mod tests { ) .unwrap(); - metrics::counter!("test1").increment(1); - metrics::counter!("test2").increment(1); - metrics::counter!("test3").increment(2); - metrics::counter!("test4", "tag" => "value1").increment(3); + counter!(name_a).increment(1); + counter!(name_b).increment(1); + counter!(name_c).increment(2); + counter!(name_d, "tag" => "value1").increment(3); assert_eq!(controller.capture_metrics().len(), 6); std::thread::sleep(Duration::from_secs_f64(IDLE_TIMEOUT * 1.5)); - metrics::counter!("test2").increment(3); + counter!(name_b).increment(3); assert_eq!(controller.capture_metrics().len(), 5); std::thread::sleep(Duration::from_secs_f64(IDLE_TIMEOUT)); - metrics::counter!("test2").increment(3); + counter!(name_b).increment(3); assert_eq!(controller.capture_metrics().len(), 4); std::thread::sleep(Duration::from_secs_f64(IDLE_TIMEOUT)); - metrics::counter!("test2").increment(3); + counter!(name_b).increment(3); assert_eq!(controller.capture_metrics().len(), 3); } } diff --git a/src/internal_events/common.rs b/src/internal_events/common.rs index 0b2ab8a4f004e..5a6f9c50ede93 100644 --- a/src/internal_events/common.rs +++ b/src/internal_events/common.rs @@ -3,7 +3,8 @@ use std::time::Instant; use vector_lib::NamedInternalEvent; pub use vector_lib::internal_event::EventsReceived; use vector_lib::internal_event::{ - ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, error_stage, + error_type, }; use vector_lib::{counter, histogram}; diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index ab0c569131b82..21edc68f9df2a 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -4,7 +4,8 @@ use tokio::time::error::Elapsed; use vector_lib::{ NamedInternalEvent, counter, histogram, internal_event::{ - ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, + error_stage, error_type, }, json_size::JsonSize, }; diff --git a/src/internal_events/file.rs b/src/internal_events/file.rs index 0bb330e336505..f1299ae751694 100644 --- a/src/internal_events/file.rs +++ b/src/internal_events/file.rs @@ -7,7 +7,8 @@ use vector_lib::{ configurable::configurable_component, counter, gauge, internal_event::{ - ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, + error_type, }, }; diff --git a/src/internal_events/lua.rs b/src/internal_events/lua.rs index bc96251af2eab..3a8779d9cd4b1 100644 --- a/src/internal_events/lua.rs +++ b/src/internal_events/lua.rs @@ -1,6 +1,7 @@ use vector_lib::NamedInternalEvent; use vector_lib::internal_event::{ - ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, + error_type, }; use vector_lib::{counter, gauge}; diff --git a/src/internal_events/socket.rs b/src/internal_events/socket.rs index 37069068c367e..d38788f46767c 100644 --- a/src/internal_events/socket.rs +++ b/src/internal_events/socket.rs @@ -3,7 +3,8 @@ use std::net::Ipv4Addr; use vector_lib::{ NamedInternalEvent, counter, histogram, internal_event::{ - ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, error_stage, error_type, + ComponentEventsDropped, CounterName, HistogramName, InternalEvent, UNINTENTIONAL, + error_stage, error_type, }, json_size::JsonSize, }; diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index 0d2ecfad63877..bd3fde83c2318 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -11,8 +11,8 @@ mod sink { use vector_lib::{ NamedInternalEvent, counter, gauge, internal_event::{ - ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, error_stage, - error_type, + ComponentEventsDropped, CounterName, GaugeName, InternalEvent, UNINTENTIONAL, + error_stage, error_type, }, }; diff --git a/src/internal_telemetry/allocations/mod.rs b/src/internal_telemetry/allocations/mod.rs index 60741470c999e..15ad82b3665fa 100644 --- a/src/internal_telemetry/allocations/mod.rs +++ b/src/internal_telemetry/allocations/mod.rs @@ -12,7 +12,10 @@ use std::{ use arr_macro::arr; use rand_distr::num_traits::ToPrimitive; -use vector_common::{counter, gauge, internal_event::{CounterName, GaugeName}}; +use vector_common::{ + counter, gauge, + internal_event::{CounterName, GaugeName}, +}; use self::allocator::Tracer; pub(crate) use self::allocator::{ diff --git a/src/sources/internal_metrics.rs b/src/sources/internal_metrics.rs index 1302072ea88c3..76dfab8849997 100644 --- a/src/sources/internal_metrics.rs +++ b/src/sources/internal_metrics.rs @@ -194,11 +194,15 @@ impl InternalMetrics<'_> { #[cfg(test)] mod tests { - #![allow(clippy::disallowed_macros)] use std::collections::BTreeMap; - use metrics::{counter, gauge, histogram}; - use vector_lib::{metric_tags, metrics::Controller}; + use strum::IntoEnumIterator; + use vector_lib::{ + counter, gauge, histogram, + internal_event::{CounterName, GaugeName, HistogramName}, + metric_tags, + metrics::Controller, + }; use super::*; use crate::{ @@ -224,14 +228,20 @@ mod tests { // There *seems* to be a race condition here (CI was flaky), so add a slight delay. std::thread::sleep(std::time::Duration::from_millis(300)); - gauge!("foo").set(1.0); - gauge!("foo").set(2.0); - counter!("bar").increment(3); - counter!("bar").increment(4); - histogram!("baz").record(5.0); - histogram!("baz").record(6.0); - histogram!("quux", "host" => "foo").record(8.0); - histogram!("quux", "host" => "foo").record(8.1); + let gauge_name = GaugeName::iter().next().unwrap(); + let counter_name = CounterName::iter().next().unwrap(); + let mut histogram_iter = HistogramName::iter(); + let histogram_name = histogram_iter.next().unwrap(); + let histogram_tagged_name = histogram_iter.next().unwrap(); + + gauge!(gauge_name).set(1.0); + gauge!(gauge_name).set(2.0); + counter!(counter_name).increment(3); + counter!(counter_name).increment(4); + histogram!(histogram_name).record(5.0); + histogram!(histogram_name).record(6.0); + histogram!(histogram_tagged_name, "host" => "foo").record(8.0); + histogram!(histogram_tagged_name, "host" => "foo").record(8.1); let controller = Controller::get().expect("no controller"); @@ -244,10 +254,16 @@ mod tests { .map(|metric| (metric.name().to_string(), metric)) .collect::>(); - assert_eq!(&MetricValue::Gauge { value: 2.0 }, output["foo"].value()); - assert_eq!(&MetricValue::Counter { value: 7.0 }, output["bar"].value()); + assert_eq!( + &MetricValue::Gauge { value: 2.0 }, + output[gauge_name.as_str()].value() + ); + assert_eq!( + &MetricValue::Counter { value: 7.0 }, + output[counter_name.as_str()].value() + ); - match &output["baz"].value() { + match &output[histogram_name.as_str()].value() { MetricValue::AggregatedHistogram { buckets, count, @@ -264,7 +280,7 @@ mod tests { _ => panic!("wrong type"), } - match &output["quux"].value() { + match &output[histogram_tagged_name.as_str()].value() { MetricValue::AggregatedHistogram { buckets, count, @@ -283,7 +299,7 @@ mod tests { } let labels = metric_tags!("host" => "foo"); - assert_eq!(Some(&labels), output["quux"].tags()); + assert_eq!(Some(&labels), output[histogram_tagged_name.as_str()].tags()); } async fn event_from_config(config: InternalMetricsConfig) -> Event { diff --git a/src/utilization.rs b/src/utilization.rs index f623837899d57..21d5f670bf1d9 100644 --- a/src/utilization.rs +++ b/src/utilization.rs @@ -342,9 +342,11 @@ impl OutputUtilization { #[cfg(test)] mod tests { - #![allow(clippy::disallowed_macros)] use mock_instant::global::MockClock; use serial_test::serial; + use strum::IntoEnumIterator; + use vector_lib::gauge; + use vector_lib::internal_event::GaugeName; use super::*; @@ -354,7 +356,7 @@ mod tests { MockClock::set_time(Duration::from_secs(100)); Timer::new( - metrics::gauge!("test_utilization"), + gauge!(GaugeName::iter().next().unwrap()), #[cfg(debug_assertions)] "test_component".into(), ) @@ -523,7 +525,7 @@ mod tests { let (mut emitter, registry) = UtilizationEmitter::new(); let key = ComponentKey::from("test_transform"); - let sender = registry.add_component(key.clone(), metrics::gauge!("utilization")); + let sender = registry.add_component(key.clone(), gauge!(GaugeName::Utilization)); let output_sender = sender.clone(); // Upstream channel carrying EventArrays. From 59257ff307e41dcb478af59472c17155fecceb14 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 May 2026 14:33:52 -0400 Subject: [PATCH 17/17] chore: replace MetricName with CounterName in Windows internal events --- src/internal_events/windows.rs | 14 +++++++------- src/internal_events/windows_event_log.rs | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/internal_events/windows.rs b/src/internal_events/windows.rs index 53eea1acaa1e0..5ea6bae62aa25 100644 --- a/src/internal_events/windows.rs +++ b/src/internal_events/windows.rs @@ -1,6 +1,6 @@ use vector_lib::{ NamedInternalEvent, counter, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, }; #[derive(Debug, NamedInternalEvent)] @@ -17,7 +17,7 @@ impl InternalEvent for WindowsServiceStart<'_> { "Started Windows Service.", ); counter!( - MetricName::WindowsServiceStartTotal, + CounterName::WindowsServiceStartTotal, "already_started" => self.already_started.to_string(), ) .increment(1); @@ -38,7 +38,7 @@ impl InternalEvent for WindowsServiceStop<'_> { "Stopped Windows Service.", ); counter!( - MetricName::WindowsServiceStopTotal, + CounterName::WindowsServiceStopTotal, "already_stopped" => self.already_stopped.to_string(), ) .increment(1); @@ -56,7 +56,7 @@ impl InternalEvent for WindowsServiceRestart<'_> { name = ?self.name, "Restarted Windows Service." ); - counter!(MetricName::WindowsServiceRestartTotal).increment(1) + counter!(CounterName::WindowsServiceRestartTotal).increment(1) } } @@ -71,7 +71,7 @@ impl InternalEvent for WindowsServiceInstall<'_> { name = ?self.name, "Installed Windows Service.", ); - counter!(MetricName::WindowsServiceInstallTotal).increment(1); + counter!(CounterName::WindowsServiceInstallTotal).increment(1); } } @@ -86,7 +86,7 @@ impl InternalEvent for WindowsServiceUninstall<'_> { name = ?self.name, "Uninstalled Windows Service.", ); - counter!(MetricName::WindowsServiceUninstallTotal).increment(1); + counter!(CounterName::WindowsServiceUninstallTotal).increment(1); } } @@ -105,7 +105,7 @@ impl InternalEvent for WindowsServiceDoesNotExistError<'_> { stage = error_stage::PROCESSING, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "service_missing", "error_type" => error_type::CONDITION_FAILED, "stage" => error_stage::PROCESSING, diff --git a/src/internal_events/windows_event_log.rs b/src/internal_events/windows_event_log.rs index dde3a75d62752..7ec356ba253ff 100644 --- a/src/internal_events/windows_event_log.rs +++ b/src/internal_events/windows_event_log.rs @@ -1,7 +1,7 @@ use tracing::error; use vector_lib::{ NamedInternalEvent, counter, - internal_event::{InternalEvent, MetricName, error_stage, error_type}, + internal_event::{CounterName, InternalEvent, error_stage, error_type}, }; #[derive(Debug, NamedInternalEvent)] @@ -24,7 +24,7 @@ impl InternalEvent for WindowsEventLogParseError { internal_log_rate_limit = true, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "parse_failed", "error_type" => error_type::PARSER_FAILED, "stage" => error_stage::PROCESSING, @@ -53,7 +53,7 @@ impl InternalEvent for WindowsEventLogQueryError { internal_log_rate_limit = true, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "query_failed", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::RECEIVING, @@ -80,7 +80,7 @@ impl InternalEvent for WindowsEventLogBookmarkError { internal_log_rate_limit = true, ); counter!( - MetricName::ComponentErrorsTotal, + CounterName::ComponentErrorsTotal, "error_code" => "bookmark_failed", "error_type" => error_type::REQUEST_FAILED, "stage" => error_stage::PROCESSING,