diff --git a/Cargo.lock b/Cargo.lock index 65e770caf3445..599cf74a5beac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3270,6 +3270,7 @@ dependencies = [ "prost-build 0.12.6", "snafu 0.8.9", "tracing 0.1.41", + "vector-config", "vector-lib", "vrl", ] diff --git a/lib/dnstap-parser/Cargo.toml b/lib/dnstap-parser/Cargo.toml index cc5527f2e5814..6501814fcc741 100644 --- a/lib/dnstap-parser/Cargo.toml +++ b/lib/dnstap-parser/Cargo.toml @@ -15,6 +15,7 @@ hickory-proto.workspace = true prost.workspace = true snafu.workspace = true tracing.workspace = true +vector-config = { path = "../vector-config" } vector-lib = { path = "../vector-lib" } vrl.workspace = true paste.workspace = true diff --git a/lib/dnstap-parser/src/internal_events.rs b/lib/dnstap-parser/src/internal_events.rs index 76ef6c6367df1..35bc4628be733 100644 --- a/lib/dnstap-parser/src/internal_events.rs +++ b/lib/dnstap-parser/src/internal_events.rs @@ -1,6 +1,8 @@ use tracing::warn; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +use vector_config::internal_event; +#[internal_event] #[derive(Debug)] pub(crate) struct DnstapParseWarning { pub error: E, diff --git a/lib/vector-buffers/src/internal_events.rs b/lib/vector-buffers/src/internal_events.rs index 2b70980790f87..74530b212ade9 100644 --- a/lib/vector-buffers/src/internal_events.rs +++ b/lib/vector-buffers/src/internal_events.rs @@ -5,7 +5,9 @@ use vector_common::{ internal_event::{InternalEvent, error_type}, registered_event, }; +use vector_config::internal_event; +#[internal_event] pub struct BufferCreated { pub buffer_id: String, pub idx: usize, @@ -35,6 +37,7 @@ impl InternalEvent for BufferCreated { } } +#[internal_event] pub struct BufferEventsReceived { pub buffer_id: String, pub idx: usize, @@ -75,6 +78,7 @@ impl InternalEvent for BufferEventsReceived { } } +#[internal_event] pub struct BufferEventsSent { pub buffer_id: String, pub idx: usize, @@ -114,6 +118,7 @@ impl InternalEvent for BufferEventsSent { } } +#[internal_event] pub struct BufferEventsDropped { pub buffer_id: String, pub idx: usize, @@ -180,6 +185,7 @@ impl InternalEvent for BufferEventsDropped { } } +#[internal_event] pub struct BufferReadError { pub error_code: &'static str, pub error: String, 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 2b7003d6c04fd..63c8fa677a07c 100644 --- a/lib/vector-common/src/internal_event/component_events_dropped.rs +++ b/lib/vector-common/src/internal_event/component_events_dropped.rs @@ -1,10 +1,12 @@ use metrics::{Counter, counter}; +use vector_config::internal_event; use super::{Count, InternalEvent, InternalEventHandle, RegisterInternalEvent}; pub const INTENTIONAL: bool = true; pub const UNINTENTIONAL: bool = false; +#[internal_event] #[derive(Debug)] pub struct ComponentEventsDropped<'a, const INTENTIONAL: bool> { pub count: usize, @@ -16,10 +18,6 @@ impl InternalEvent for ComponentEventsDropped<'_, INTEN let count = self.count; self.register().emit(Count(count)); } - - fn name(&self) -> Option<&'static str> { - Some("ComponentEventsDropped") - } } impl<'a, const INTENTIONAL: bool> From<&'a str> for ComponentEventsDropped<'a, INTENTIONAL> { diff --git a/lib/vector-common/src/internal_event/mod.rs b/lib/vector-common/src/internal_event/mod.rs index 83c06260c0d5e..c737f4bf44b7c 100644 --- a/lib/vector-common/src/internal_event/mod.rs +++ b/lib/vector-common/src/internal_event/mod.rs @@ -24,13 +24,12 @@ pub use service::{CallError, PollReadyError}; use crate::json_size::JsonSize; -pub trait InternalEvent: Sized { - fn emit(self); +pub trait NamedInternalEvent { + fn name(&self) -> &'static str; +} - // Optional for backwards compat until all events implement this - fn name(&self) -> Option<&'static str> { - None - } +pub trait InternalEvent: NamedInternalEvent + Sized { + fn emit(self); } #[allow(clippy::module_name_repetitions)] @@ -60,29 +59,27 @@ impl InternalEvent for DefaultName { fn emit(self) { self.event.emit(); } +} - fn name(&self) -> Option<&'static str> { - Some(self.event.name().unwrap_or(self.name)) +impl NamedInternalEvent for DefaultName { + fn name(&self) -> &'static str { + self.event.name() } } -impl RegisterInternalEvent for DefaultName { +impl RegisterInternalEvent for DefaultName { type Handle = E::Handle; fn register(self) -> Self::Handle { self.event.register() } - fn name(&self) -> Option<&'static str> { - Some(self.event.name().unwrap_or(self.name)) - } + fn name(&self) -> Option<&'static str> { Some(NamedInternalEvent::name(&self.event)) } } #[cfg(any(test, feature = "test"))] pub fn emit(event: impl InternalEvent) { - if let Some(name) = event.name() { - super::event_test_util::record_internal_event(name); - } + super::event_test_util::record_internal_event(event.name()); event.emit(); } diff --git a/lib/vector-common/src/internal_event/service.rs b/lib/vector-common/src/internal_event/service.rs index e7d9748e45f45..1209fb4a93bce 100644 --- a/lib/vector-common/src/internal_event/service.rs +++ b/lib/vector-common/src/internal_event/service.rs @@ -1,7 +1,9 @@ use metrics::counter; +use vector_config::internal_event; use super::{ComponentEventsDropped, InternalEvent, UNINTENTIONAL, emit, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct PollReadyError { pub error: E, @@ -23,12 +25,9 @@ impl InternalEvent for PollReadyError { ) .increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("ServicePollReadyError") - } } +#[internal_event] #[derive(Debug)] pub struct CallError { pub error: E, @@ -59,8 +58,4 @@ impl InternalEvent for CallError { count: self.count, }); } - - fn name(&self) -> Option<&'static str> { - Some("ServiceCallError") - } } diff --git a/lib/vector-config-macros/src/internal_event.rs b/lib/vector-config-macros/src/internal_event.rs new file mode 100644 index 0000000000000..8d5d668ddf0f9 --- /dev/null +++ b/lib/vector-config-macros/src/internal_event.rs @@ -0,0 +1,41 @@ +use proc_macro::TokenStream; +use quote::quote; +use syn::{parse_macro_input, ItemStruct}; + +// #[internal_event] attribute macro implementation. +// +// Apply to a struct that also implements `InternalEvent`. This generates an +// implementation of `NamedInternalEvent` so `InternalEvent::name()` returns +// a canonical &'static str for the event's type. +pub fn internal_event_impl(item: TokenStream) -> TokenStream { + let item_struct = parse_macro_input!(item as ItemStruct); + + let ident = &item_struct.ident; + let generics = item_struct.generics.clone(); + let (impl_generics, ty_generics, where_clause2) = generics.split_for_impl(); + + // Use a path that works from both vector-common (crate::internal_event) + // and from other crates using vector-lib (vector_lib::internal_event). + // For crates that don't depend on vector-lib but do depend on vector-common, + // we use vector_common::internal_event. + let pkg_name = std::env::var("CARGO_PKG_NAME").unwrap_or_default(); + let internal_event_path = if pkg_name == "vector-common" { + quote! { crate::internal_event } + } else if pkg_name == "vector-buffers" || pkg_name.starts_with("vector-") { + // Most vector-* crates depend on vector-common but not vector-lib + quote! { ::vector_common::internal_event } + } else { + // Main vector crate and its internal modules use vector_lib + quote! { ::vector_lib::internal_event } + }; + + let expanded = quote! { + #item_struct + + impl #impl_generics #internal_event_path::NamedInternalEvent for #ident #ty_generics #where_clause2 { + fn name(&self) -> &'static str { stringify!(#ident) } + } + }; + + TokenStream::from(expanded) +} diff --git a/lib/vector-config-macros/src/lib.rs b/lib/vector-config-macros/src/lib.rs index cfb10e09c258b..af933b094ea30 100644 --- a/lib/vector-config-macros/src/lib.rs +++ b/lib/vector-config-macros/src/lib.rs @@ -7,6 +7,7 @@ mod attrs; mod component_name; mod configurable; mod configurable_component; +mod internal_event; /// Designates a type as being part of a Vector configuration. /// @@ -110,3 +111,41 @@ pub fn derive_configurable(input: TokenStream) -> TokenStream { pub fn derive_component_name(input: TokenStream) -> TokenStream { component_name::derive_component_name_impl(input) } + +/// Marks an internal event struct for automatic name reporting. +/// +/// Apply this attribute to the struct type that implements `InternalEvent`. +/// It generates an implementation of `NamedInternalEvent` so `InternalEvent::name()` +/// returns a stable, compile-time string for the event type. +/// +/// Usage: +/// +/// ```ignore +/// use vector_config::internal_event; +/// use vector_lib::internal_event::InternalEvent; +/// +/// #[internal_event] +/// #[derive(Debug)] +/// pub struct UdpSendIncompleteError { +/// pub data_size: usize, +/// pub sent: usize, +/// } +/// +/// impl InternalEvent for UdpSendIncompleteError { +/// fn emit(self) { +/// // ... emit metrics/logging ... +/// } +/// } +/// +/// // Later, `UdpSendIncompleteError.name()` yields the full type path. +/// ``` +/// +/// Notes: +/// - The attribute has no parameters. +/// - Works with generics and lifetimes on the struct. +/// - The returned name is the struct identifier, via `stringify!(TypeName)`. +/// This avoids canonicalized module paths and yields stable event names. +#[proc_macro_attribute] +pub fn internal_event(_attrs: TokenStream, item: TokenStream) -> TokenStream { + internal_event::internal_event_impl(item) +} diff --git a/src/enrichment_tables/memory/internal_events.rs b/src/enrichment_tables/memory/internal_events.rs index 455a9069a16c0..42fb80f0d3bb4 100644 --- a/src/enrichment_tables/memory/internal_events.rs +++ b/src/enrichment_tables/memory/internal_events.rs @@ -1,4 +1,5 @@ use metrics::{counter, gauge}; +use vector_config::internal_event; use vector_lib::{configurable::configurable_component, internal_event::InternalEvent}; /// Configuration of internal metrics for enrichment memory table. @@ -14,6 +15,7 @@ pub struct InternalMetricsConfig { pub include_key_tag: bool, } +#[internal_event] #[derive(Debug)] pub(crate) struct MemoryEnrichmentTableRead<'a> { pub key: &'a str, @@ -32,12 +34,9 @@ impl InternalEvent for MemoryEnrichmentTableRead<'_> { counter!("memory_enrichment_table_reads_total",).increment(1); } } - - fn name(&self) -> Option<&'static str> { - Some("MemoryEnrichmentTableRead") - } } +#[internal_event] #[derive(Debug)] pub(crate) struct MemoryEnrichmentTableInserted<'a> { pub key: &'a str, @@ -56,12 +55,9 @@ impl InternalEvent for MemoryEnrichmentTableInserted<'_> { counter!("memory_enrichment_table_insertions_total",).increment(1); } } - - fn name(&self) -> Option<&'static str> { - Some("MemoryEnrichmentTableInserted") - } } +#[internal_event] #[derive(Debug)] pub(crate) struct MemoryEnrichmentTableFlushed { pub new_objects_count: usize, @@ -74,12 +70,9 @@ impl InternalEvent for MemoryEnrichmentTableFlushed { 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); } - - fn name(&self) -> Option<&'static str> { - Some("MemoryEnrichmentTableFlushed") - } } +#[internal_event] #[derive(Debug)] pub(crate) struct MemoryEnrichmentTableTtlExpired<'a> { pub key: &'a str, @@ -98,12 +91,9 @@ impl InternalEvent for MemoryEnrichmentTableTtlExpired<'_> { counter!("memory_enrichment_table_ttl_expirations",).increment(1); } } - - fn name(&self) -> Option<&'static str> { - Some("MemoryEnrichmentTableTtlExpired") - } } +#[internal_event] #[derive(Debug)] pub(crate) struct MemoryEnrichmentTableReadFailed<'a> { pub key: &'a str, @@ -122,12 +112,9 @@ impl InternalEvent for MemoryEnrichmentTableReadFailed<'_> { counter!("memory_enrichment_table_failed_reads",).increment(1); } } - - fn name(&self) -> Option<&'static str> { - Some("MemoryEnrichmentTableReadFailed") - } } +#[internal_event] #[derive(Debug)] pub(crate) struct MemoryEnrichmentTableInsertFailed<'a> { pub key: &'a str, @@ -146,8 +133,4 @@ impl InternalEvent for MemoryEnrichmentTableInsertFailed<'_> { counter!("memory_enrichment_table_failed_insertions",).increment(1); } } - - fn name(&self) -> Option<&'static str> { - Some("MemoryEnrichmentTableInsertFailed") - } } diff --git a/src/internal_events/aggregate.rs b/src/internal_events/aggregate.rs index 7fc84bda29abf..72b4f6cec4239 100644 --- a/src/internal_events/aggregate.rs +++ b/src/internal_events/aggregate.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; +#[internal_event] #[derive(Debug)] pub struct AggregateEventRecorded; @@ -10,6 +12,7 @@ impl InternalEvent for AggregateEventRecorded { } } +#[internal_event] #[derive(Debug)] pub struct AggregateFlushed; @@ -19,6 +22,7 @@ impl InternalEvent for AggregateFlushed { } } +#[internal_event] #[derive(Debug)] pub struct AggregateUpdateFailed; diff --git a/src/internal_events/amqp.rs b/src/internal_events/amqp.rs index ea3127fdb55ff..9a8d9c822a8b7 100644 --- a/src/internal_events/amqp.rs +++ b/src/internal_events/amqp.rs @@ -1,8 +1,10 @@ #[cfg(feature = "sources-amqp")] pub mod source { use metrics::counter; + use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; + #[internal_event] #[derive(Debug)] pub struct AmqpBytesReceived { pub byte_size: usize, @@ -24,6 +26,7 @@ pub mod source { } } + #[internal_event] #[derive(Debug)] pub struct AmqpEventError { pub error: lapin::Error, @@ -46,6 +49,7 @@ pub mod source { } } + #[internal_event] #[derive(Debug)] pub struct AmqpAckError { pub error: lapin::Error, @@ -68,6 +72,7 @@ pub mod source { } } + #[internal_event] #[derive(Debug)] pub struct AmqpRejectError { pub error: lapin::Error, diff --git a/src/internal_events/apache_metrics.rs b/src/internal_events/apache_metrics.rs index 1cf7e4c093db4..aed5a7d4fe16f 100644 --- a/src/internal_events/apache_metrics.rs +++ b/src/internal_events/apache_metrics.rs @@ -1,4 +1,5 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, @@ -6,6 +7,7 @@ use vector_lib::{ use crate::sources::apache_metrics; +#[internal_event] #[derive(Debug)] pub struct ApacheMetricsEventsReceived<'a> { pub byte_size: JsonSize, @@ -30,6 +32,7 @@ impl InternalEvent for ApacheMetricsEventsReceived<'_> { } } +#[internal_event] #[derive(Debug)] pub struct ApacheMetricsParseError<'a> { pub error: apache_metrics::ParseError, diff --git a/src/internal_events/api.rs b/src/internal_events/api.rs index c6163b67925c9..2c4f50720a7fa 100644 --- a/src/internal_events/api.rs +++ b/src/internal_events/api.rs @@ -1,8 +1,10 @@ use std::net::SocketAddr; use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; +#[internal_event] #[derive(Debug)] pub struct ApiStarted { pub addr: SocketAddr, diff --git a/src/internal_events/aws.rs b/src/internal_events/aws.rs index 341205f0846ab..e91137e6fa5aa 100644 --- a/src/internal_events/aws.rs +++ b/src/internal_events/aws.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; +#[internal_event] pub struct AwsBytesSent { pub byte_size: usize, pub region: Option, diff --git a/src/internal_events/aws_cloudwatch_logs.rs b/src/internal_events/aws_cloudwatch_logs.rs index b69cc6e42a41e..ab2ec595482fe 100644 --- a/src/internal_events/aws_cloudwatch_logs.rs +++ b/src/internal_events/aws_cloudwatch_logs.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct AwsCloudwatchLogsMessageSizeError { pub size: usize, diff --git a/src/internal_events/aws_ec2_metadata.rs b/src/internal_events/aws_ec2_metadata.rs index 3e548440731dd..e75d7646b0ee4 100644 --- a/src/internal_events/aws_ec2_metadata.rs +++ b/src/internal_events/aws_ec2_metadata.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct AwsEc2MetadataRefreshSuccessful; @@ -11,6 +13,7 @@ impl InternalEvent for AwsEc2MetadataRefreshSuccessful { } } +#[internal_event] #[derive(Debug)] pub struct AwsEc2MetadataRefreshError { pub error: crate::Error, diff --git a/src/internal_events/aws_ecs_metrics.rs b/src/internal_events/aws_ecs_metrics.rs index 37286c9bfb4aa..cc9511addbaff 100644 --- a/src/internal_events/aws_ecs_metrics.rs +++ b/src/internal_events/aws_ecs_metrics.rs @@ -1,11 +1,13 @@ use std::borrow::Cow; use metrics::counter; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, }; +#[internal_event] #[derive(Debug)] pub struct AwsEcsMetricsEventsReceived<'a> { pub byte_size: JsonSize, @@ -35,6 +37,7 @@ impl InternalEvent for AwsEcsMetricsEventsReceived<'_> { } } +#[internal_event] #[derive(Debug)] pub struct AwsEcsMetricsParseError<'a> { pub error: serde_json::Error, diff --git a/src/internal_events/aws_kinesis.rs b/src/internal_events/aws_kinesis.rs index 234d2f4972e1e..400108bef9f9e 100644 --- a/src/internal_events/aws_kinesis.rs +++ b/src/internal_events/aws_kinesis.rs @@ -1,9 +1,11 @@ /// Used in both `aws_kinesis_streams` and `aws_kinesis_firehose` sinks use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct AwsKinesisStreamNoPartitionKeyError<'a> { pub partition_key_field: &'a str, diff --git a/src/internal_events/aws_kinesis_firehose.rs b/src/internal_events/aws_kinesis_firehose.rs index 28655173adb95..e427f748fe53c 100644 --- a/src/internal_events/aws_kinesis_firehose.rs +++ b/src/internal_events/aws_kinesis_firehose.rs @@ -1,9 +1,11 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use super::prelude::{http_error_code, io_error_code}; use crate::sources::aws_kinesis_firehose::Compression; +#[internal_event] #[derive(Debug)] pub struct AwsKinesisFirehoseRequestReceived<'a> { pub request_id: Option<&'a str>, @@ -21,6 +23,7 @@ impl InternalEvent for AwsKinesisFirehoseRequestReceived<'_> { } } +#[internal_event] #[derive(Debug)] pub struct AwsKinesisFirehoseRequestError<'a> { request_id: Option<&'a str>, @@ -59,6 +62,7 @@ impl InternalEvent for AwsKinesisFirehoseRequestError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct AwsKinesisFirehoseAutomaticRecordDecodeError { pub compression: Compression, diff --git a/src/internal_events/aws_sqs.rs b/src/internal_events/aws_sqs.rs index 34aaf4d4a3b30..b374c6fafef73 100644 --- a/src/internal_events/aws_sqs.rs +++ b/src/internal_events/aws_sqs.rs @@ -3,6 +3,7 @@ use metrics::counter; #[cfg(feature = "sources-aws_s3")] pub use s3::*; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; #[cfg(any(feature = "sources-aws_s3", feature = "sources-aws_sqs"))] use vector_lib::internal_event::{error_stage, error_type}; @@ -17,6 +18,7 @@ mod s3 { use super::*; use crate::sources::aws_s3::sqs::ProcessingError; + #[internal_event] #[derive(Debug)] pub struct SqsMessageProcessingError<'a> { pub message_id: &'a str, @@ -44,6 +46,7 @@ mod s3 { } } + #[internal_event] #[derive(Debug)] pub struct SqsMessageDeleteSucceeded { pub message_ids: Vec, @@ -60,6 +63,7 @@ mod s3 { } } + #[internal_event] #[derive(Debug)] pub struct SqsMessageDeletePartialError { pub entries: Vec, @@ -88,6 +92,7 @@ mod s3 { } } + #[internal_event] #[derive(Debug)] pub struct SqsMessageDeleteBatchError { pub entries: Vec, @@ -118,6 +123,7 @@ mod s3 { } } + #[internal_event] #[derive(Debug)] pub struct SqsMessageSentSucceeded { pub message_ids: Vec, @@ -134,6 +140,7 @@ mod s3 { } } + #[internal_event] #[derive(Debug)] pub struct SqsMessageSentPartialError { pub entries: Vec, @@ -162,6 +169,7 @@ mod s3 { } } + #[internal_event] #[derive(Debug)] pub struct SqsMessageSendBatchError { pub entries: Vec, @@ -193,6 +201,7 @@ mod s3 { } } +#[internal_event] #[derive(Debug)] pub struct SqsMessageReceiveError<'a, E> { pub error: &'a E, @@ -218,6 +227,7 @@ impl InternalEvent for SqsMessageReceiveError<'_, E> { } } +#[internal_event] #[derive(Debug)] pub struct SqsMessageReceiveSucceeded { pub count: usize, @@ -231,6 +241,7 @@ impl InternalEvent for SqsMessageReceiveSucceeded { } } +#[internal_event] #[derive(Debug)] pub struct SqsMessageProcessingSucceeded<'a> { pub message_id: &'a str, @@ -246,6 +257,7 @@ impl InternalEvent for SqsMessageProcessingSucceeded<'_> { // AWS SQS source #[cfg(feature = "sources-aws_sqs")] +#[internal_event] #[derive(Debug)] pub struct SqsMessageDeleteError<'a, E> { pub error: &'a E, @@ -272,6 +284,7 @@ impl InternalEvent for SqsMessageDeleteError<'_, E> { // AWS s3 source +#[internal_event] #[derive(Debug)] pub struct SqsS3EventRecordInvalidEventIgnored<'a> { pub bucket: &'a str, diff --git a/src/internal_events/batch.rs b/src/internal_events/batch.rs index d0cb72b305570..b60988eb2ccd4 100644 --- a/src/internal_events/batch.rs +++ b/src/internal_events/batch.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct LargeEventDroppedError { pub(crate) length: usize, diff --git a/src/internal_events/codecs.rs b/src/internal_events/codecs.rs index b9222d6be11fc..1ab3c21e01112 100644 --- a/src/internal_events/codecs.rs +++ b/src/internal_events/codecs.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct DecoderFramingError { pub error: E, @@ -28,6 +30,7 @@ impl InternalEvent for DecoderFramingError { } } +#[internal_event] #[derive(Debug)] pub struct DecoderDeserializeError<'a> { pub error: &'a crate::Error, @@ -53,6 +56,7 @@ impl InternalEvent for DecoderDeserializeError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct EncoderFramingError<'a> { pub error: &'a vector_lib::codecs::encoding::BoxedFramingError, @@ -80,6 +84,7 @@ impl InternalEvent for EncoderFramingError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct EncoderSerializeError<'a> { pub error: &'a crate::Error, @@ -107,6 +112,7 @@ impl InternalEvent for EncoderSerializeError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct EncoderWriteError<'a, E> { pub error: &'a E, diff --git a/src/internal_events/common.rs b/src/internal_events/common.rs index 20d2ca6c4466c..edeaa77c38d3c 100644 --- a/src/internal_events/common.rs +++ b/src/internal_events/common.rs @@ -2,10 +2,12 @@ use std::time::Instant; use metrics::{counter, histogram}; pub use vector_lib::internal_event::EventsReceived; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct EndpointBytesReceived<'a> { pub byte_size: usize, @@ -30,6 +32,7 @@ impl InternalEvent for EndpointBytesReceived<'_> { } } +#[internal_event] #[derive(Debug)] pub struct EndpointBytesSent<'a> { pub byte_size: usize, @@ -54,6 +57,7 @@ impl InternalEvent for EndpointBytesSent<'_> { } } +#[internal_event] #[derive(Debug)] pub struct SocketOutgoingConnectionError { pub error: E, @@ -81,6 +85,7 @@ impl InternalEvent for SocketOutgoingConnectionError { const STREAM_CLOSED: &str = "stream_closed"; +#[internal_event] #[derive(Debug)] pub struct StreamClosedError { pub count: usize, @@ -109,6 +114,7 @@ impl InternalEvent for StreamClosedError { } } +#[internal_event] #[derive(Debug)] pub struct CollectionCompleted { pub start: Instant, @@ -123,6 +129,7 @@ impl InternalEvent for CollectionCompleted { } } +#[internal_event] #[derive(Debug)] pub struct SinkRequestBuildError { pub error: E, diff --git a/src/internal_events/conditions.rs b/src/internal_events/conditions.rs index e3b32041bb561..dcafa49f79229 100644 --- a/src/internal_events/conditions.rs +++ b/src/internal_events/conditions.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug, Copy, Clone)] pub struct VrlConditionExecutionError<'a> { pub error: &'a str, diff --git a/src/internal_events/config.rs b/src/internal_events/config.rs index 0526a758194b5..c0e610541628f 100644 --- a/src/internal_events/config.rs +++ b/src/internal_events/config.rs @@ -1,7 +1,9 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; #[derive(Debug)] +#[internal_event] pub struct ConfigReloadRejected { reason: ReloadRejectReason, } @@ -39,10 +41,6 @@ impl InternalEvent for ConfigReloadRejected { } } } - - fn name(&self) -> Option<&'static str> { - Some("ConfigReloadRejected") - } } impl ConfigReloadRejected { @@ -75,6 +73,7 @@ impl ReloadRejectReason { } #[derive(Debug)] +#[internal_event] pub struct ConfigReloaded; impl InternalEvent for ConfigReloaded { @@ -86,8 +85,4 @@ impl InternalEvent for ConfigReloaded { counter!("config_reloaded",).increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("ConfigReloaded") - } } diff --git a/src/internal_events/datadog_agent.rs b/src/internal_events/datadog_agent.rs index f6aff7035d31f..7e27a409e5f6a 100644 --- a/src/internal_events/datadog_agent.rs +++ b/src/internal_events/datadog_agent.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct DatadogAgentJsonParseError<'a> { pub error: &'a serde_json::Error, diff --git a/src/internal_events/datadog_metrics.rs b/src/internal_events/datadog_metrics.rs index 801615c879e43..f8fb41b09bc6a 100644 --- a/src/internal_events/datadog_metrics.rs +++ b/src/internal_events/datadog_metrics.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct DatadogMetricsEncodingError<'a> { pub reason: &'a str, diff --git a/src/internal_events/datadog_traces.rs b/src/internal_events/datadog_traces.rs index 5a1503fce56e7..2ad8fd0107291 100644 --- a/src/internal_events/datadog_traces.rs +++ b/src/internal_events/datadog_traces.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct DatadogTracesEncodingError { pub error_message: &'static str, @@ -37,6 +39,7 @@ impl InternalEvent for DatadogTracesEncodingError { } } +#[internal_event] #[derive(Debug)] pub struct DatadogTracesAPMStatsError { pub error: E, diff --git a/src/internal_events/dedupe.rs b/src/internal_events/dedupe.rs index c4a781de2c10b..6ac8847f727a6 100644 --- a/src/internal_events/dedupe.rs +++ b/src/internal_events/dedupe.rs @@ -1,5 +1,7 @@ +use vector_config::internal_event; use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; +#[internal_event] #[derive(Debug)] pub struct DedupeEventsDropped { pub count: usize, diff --git a/src/internal_events/demo_logs.rs b/src/internal_events/demo_logs.rs index 796c9e9fca7bd..20bc49441e00f 100644 --- a/src/internal_events/demo_logs.rs +++ b/src/internal_events/demo_logs.rs @@ -1,5 +1,7 @@ +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; +#[internal_event] #[derive(Debug)] pub struct DemoLogsEventProcessed; diff --git a/src/internal_events/dnstap.rs b/src/internal_events/dnstap.rs index bddfb989dddc5..0f49ebbd63852 100644 --- a/src/internal_events/dnstap.rs +++ b/src/internal_events/dnstap.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub(crate) struct DnstapParseError { pub error: E, diff --git a/src/internal_events/docker_logs.rs b/src/internal_events/docker_logs.rs index 25b1300220e45..494c4028cf680 100644 --- a/src/internal_events/docker_logs.rs +++ b/src/internal_events/docker_logs.rs @@ -1,11 +1,13 @@ use bollard::errors::Error; use chrono::ParseError; use metrics::counter; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, }; +#[internal_event] #[derive(Debug)] pub struct DockerLogsEventsReceived<'a> { pub byte_size: JsonSize, @@ -31,6 +33,7 @@ impl InternalEvent for DockerLogsEventsReceived<'_> { } } +#[internal_event] #[derive(Debug)] pub struct DockerLogsContainerEventReceived<'a> { pub container_id: &'a str, @@ -48,6 +51,7 @@ impl InternalEvent for DockerLogsContainerEventReceived<'_> { } } +#[internal_event] #[derive(Debug)] pub struct DockerLogsContainerWatch<'a> { pub container_id: &'a str, @@ -63,6 +67,7 @@ impl InternalEvent for DockerLogsContainerWatch<'_> { } } +#[internal_event] #[derive(Debug)] pub struct DockerLogsContainerUnwatch<'a> { pub container_id: &'a str, @@ -78,6 +83,7 @@ impl InternalEvent for DockerLogsContainerUnwatch<'_> { } } +#[internal_event] #[derive(Debug)] pub struct DockerLogsCommunicationError<'a> { pub error: Error, @@ -103,6 +109,7 @@ impl InternalEvent for DockerLogsCommunicationError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct DockerLogsContainerMetadataFetchError<'a> { pub error: Error, @@ -129,6 +136,7 @@ impl InternalEvent for DockerLogsContainerMetadataFetchError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct DockerLogsTimestampParseError<'a> { pub error: ParseError, @@ -155,6 +163,7 @@ impl InternalEvent for DockerLogsTimestampParseError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct DockerLogsLoggingDriverUnsupportedError<'a> { pub container_id: &'a str, diff --git a/src/internal_events/encoding_transcode.rs b/src/internal_events/encoding_transcode.rs index 0a377f52ca1ee..d225c0f0d5191 100644 --- a/src/internal_events/encoding_transcode.rs +++ b/src/internal_events/encoding_transcode.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; +#[internal_event] #[derive(Debug)] pub struct DecoderBomRemoval { pub from_encoding: &'static str, @@ -17,6 +19,7 @@ impl InternalEvent for DecoderBomRemoval { } } +#[internal_event] #[derive(Debug)] pub struct DecoderMalformedReplacement { pub from_encoding: &'static str, @@ -35,6 +38,7 @@ impl InternalEvent for DecoderMalformedReplacement { } } +#[internal_event] #[derive(Debug)] pub struct EncoderUnmappableReplacement { pub to_encoding: &'static str, diff --git a/src/internal_events/eventstoredb_metrics.rs b/src/internal_events/eventstoredb_metrics.rs index a18ac87f515a1..9136b9fbe8ccd 100644 --- a/src/internal_events/eventstoredb_metrics.rs +++ b/src/internal_events/eventstoredb_metrics.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct EventStoreDbMetricsHttpError { pub error: crate::Error, @@ -24,6 +26,7 @@ impl InternalEvent for EventStoreDbMetricsHttpError { } } +#[internal_event] #[derive(Debug)] pub struct EventStoreDbStatsParsingError { pub error: serde_json::Error, diff --git a/src/internal_events/exec.rs b/src/internal_events/exec.rs index 2ea26ada8239c..23336a22390d9 100644 --- a/src/internal_events/exec.rs +++ b/src/internal_events/exec.rs @@ -2,6 +2,7 @@ use std::time::Duration; use metrics::{counter, histogram}; use tokio::time::error::Elapsed; +use vector_config::internal_event; use vector_lib::{ internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -11,6 +12,7 @@ use vector_lib::{ use super::prelude::io_error_code; +#[internal_event] #[derive(Debug)] pub struct ExecEventsReceived<'a> { pub count: usize, @@ -39,6 +41,7 @@ impl InternalEvent for ExecEventsReceived<'_> { } } +#[internal_event] #[derive(Debug)] pub struct ExecFailedError<'a> { pub command: &'a str, @@ -67,6 +70,7 @@ impl InternalEvent for ExecFailedError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct ExecTimeoutError<'a> { pub command: &'a str, @@ -95,6 +99,7 @@ impl InternalEvent for ExecTimeoutError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct ExecCommandExecuted<'a> { pub command: &'a str, @@ -182,6 +187,7 @@ impl std::fmt::Display for ExecFailedToSignalChild { } } +#[internal_event] pub struct ExecFailedToSignalChildError<'a> { pub command: &'a tokio::process::Command, pub error: ExecFailedToSignalChild, @@ -208,6 +214,7 @@ impl InternalEvent for ExecFailedToSignalChildError<'_> { } } +#[internal_event] pub struct ExecChannelClosedError; impl InternalEvent for ExecChannelClosedError { diff --git a/src/internal_events/expansion.rs b/src/internal_events/expansion.rs index 5d4c0f9c1b20a..e54f332b66ad5 100644 --- a/src/internal_events/expansion.rs +++ b/src/internal_events/expansion.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] pub struct PairExpansionError<'a> { pub key: &'a str, pub value: &'a str, diff --git a/src/internal_events/file.rs b/src/internal_events/file.rs index 4aeade8511af3..2da68e30ed203 100644 --- a/src/internal_events/file.rs +++ b/src/internal_events/file.rs @@ -3,6 +3,7 @@ use std::borrow::Cow; use metrics::{counter, gauge}; +use vector_config::internal_event; use vector_lib::{ configurable::configurable_component, internal_event::{ @@ -26,6 +27,7 @@ pub struct FileInternalMetricsConfig { pub include_file_tag: bool, } +#[internal_event] #[derive(Debug)] pub struct FileOpen { pub count: usize, @@ -37,6 +39,7 @@ impl InternalEvent for FileOpen { } } +#[internal_event] #[derive(Debug)] pub struct FileBytesSent<'a> { pub byte_size: usize, @@ -68,6 +71,7 @@ impl InternalEvent for FileBytesSent<'_> { } } +#[internal_event] #[derive(Debug)] pub struct FileIoError<'a, P> { pub error: std::io::Error, @@ -111,6 +115,7 @@ mod source { use bytes::BytesMut; use metrics::counter; + use vector_config::internal_event; use vector_lib::{ emit, file_source_common::internal_events::FileSourceInternalEvents, @@ -120,6 +125,7 @@ mod source { use super::{FileOpen, InternalEvent}; + #[internal_event] #[derive(Debug)] pub struct FileBytesReceived<'a> { pub byte_size: usize, @@ -151,6 +157,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileEventsReceived<'a> { pub count: usize, @@ -186,6 +193,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileChecksumFailed<'a> { pub file: &'a Path, @@ -210,6 +218,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileFingerprintReadError<'a> { pub file: &'a Path, @@ -250,6 +259,7 @@ mod source { const DELETION_FAILED: &str = "deletion_failed"; + #[internal_event] #[derive(Debug)] pub struct FileDeleteError<'a> { pub file: &'a Path, @@ -288,6 +298,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileDeleted<'a> { pub file: &'a Path, @@ -312,6 +323,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileUnwatched<'a> { pub file: &'a Path, @@ -343,6 +355,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] struct FileWatchError<'a> { pub file: &'a Path, @@ -381,6 +394,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileResumed<'a> { pub file: &'a Path, @@ -407,6 +421,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileAdded<'a> { pub file: &'a Path, @@ -431,6 +446,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileCheckpointed { pub count: usize, @@ -448,6 +464,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileCheckpointWriteError { pub error: Error, @@ -473,6 +490,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct PathGlobbingError<'a> { pub path: &'a Path, @@ -500,6 +518,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct FileLineTooBigError<'a> { pub truncated_bytes: &'a BytesMut, diff --git a/src/internal_events/file_descriptor.rs b/src/internal_events/file_descriptor.rs index 734edd6f64c8a..c93f57dfc9a29 100644 --- a/src/internal_events/file_descriptor.rs +++ b/src/internal_events/file_descriptor.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct FileDescriptorReadError { pub error: E, diff --git a/src/internal_events/fluent.rs b/src/internal_events/fluent.rs index 69a8133f519d2..c5a6cfbc951f0 100644 --- a/src/internal_events/fluent.rs +++ b/src/internal_events/fluent.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use crate::sources::fluent::DecodeError; +#[internal_event] #[derive(Debug)] pub struct FluentMessageReceived { pub byte_size: u64, @@ -14,6 +16,7 @@ impl InternalEvent for FluentMessageReceived { } } +#[internal_event] #[derive(Debug)] pub struct FluentMessageDecodeError<'a> { pub error: &'a DecodeError, diff --git a/src/internal_events/gcp_pubsub.rs b/src/internal_events/gcp_pubsub.rs index eda31c4b2cd68..f6a61935dd927 100644 --- a/src/internal_events/gcp_pubsub.rs +++ b/src/internal_events/gcp_pubsub.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] pub struct GcpPubsubConnectError { pub error: tonic::transport::Error, } @@ -26,6 +28,7 @@ impl InternalEvent for GcpPubsubConnectError { } } +#[internal_event] pub struct GcpPubsubStreamingPullError { pub error: tonic::Status, } @@ -51,6 +54,7 @@ impl InternalEvent for GcpPubsubStreamingPullError { } } +#[internal_event] pub struct GcpPubsubReceiveError { pub error: tonic::Status, } diff --git a/src/internal_events/grpc.rs b/src/internal_events/grpc.rs index afb81f626d321..cbc102ab0bae1 100644 --- a/src/internal_events/grpc.rs +++ b/src/internal_events/grpc.rs @@ -3,10 +3,12 @@ use std::time::Duration; use http::response::Response; use metrics::{counter, histogram}; use tonic::Code; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; const GRPC_STATUS_LABEL: &str = "grpc_status"; +#[internal_event] #[derive(Debug)] pub struct GrpcServerRequestReceived; @@ -16,6 +18,7 @@ impl InternalEvent for GrpcServerRequestReceived { } } +#[internal_event] #[derive(Debug)] pub struct GrpcServerResponseSent<'a, B> { pub response: &'a Response, @@ -38,6 +41,7 @@ impl InternalEvent for GrpcServerResponseSent<'_, B> { } } +#[internal_event] #[derive(Debug)] pub struct GrpcInvalidCompressionSchemeError<'a> { pub status: &'a tonic::Status, @@ -61,6 +65,7 @@ impl InternalEvent for GrpcInvalidCompressionSchemeError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct GrpcError { pub error: E, diff --git a/src/internal_events/heartbeat.rs b/src/internal_events/heartbeat.rs index 8197237bbceff..456653d5f5931 100644 --- a/src/internal_events/heartbeat.rs +++ b/src/internal_events/heartbeat.rs @@ -1,10 +1,12 @@ use std::time::Instant; use metrics::gauge; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; use crate::built_info; +#[internal_event] #[derive(Debug)] pub struct Heartbeat { pub since: Instant, diff --git a/src/internal_events/host_metrics.rs b/src/internal_events/host_metrics.rs index 7c54500f5d1f7..b5e02862855b3 100644 --- a/src/internal_events/host_metrics.rs +++ b/src/internal_events/host_metrics.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct HostMetricsScrapeError { pub message: &'static str, @@ -24,6 +26,7 @@ impl InternalEvent for HostMetricsScrapeError { } } +#[internal_event] #[derive(Debug)] pub struct HostMetricsScrapeDetailError { pub message: &'static str, @@ -49,6 +52,7 @@ impl InternalEvent for HostMetricsScrapeDetailError { } } +#[internal_event] #[derive(Debug)] pub struct HostMetricsScrapeFilesystemError { pub message: &'static str, diff --git a/src/internal_events/http.rs b/src/internal_events/http.rs index 436d42b297a18..a61cc236a03a7 100644 --- a/src/internal_events/http.rs +++ b/src/internal_events/http.rs @@ -2,6 +2,7 @@ use std::{error::Error, time::Duration}; use http::Response; use metrics::{counter, histogram}; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, @@ -10,6 +11,7 @@ use vector_lib::{ const HTTP_STATUS_LABEL: &str = "status"; #[derive(Debug)] +#[internal_event] pub struct HttpServerRequestReceived; impl InternalEvent for HttpServerRequestReceived { @@ -23,6 +25,7 @@ impl InternalEvent for HttpServerRequestReceived { } #[derive(Debug)] +#[internal_event] pub struct HttpServerResponseSent<'a, B> { pub response: &'a Response, pub latency: Duration, @@ -40,6 +43,7 @@ impl InternalEvent for HttpServerResponseSent<'_, B> { } #[derive(Debug)] +#[internal_event] pub struct HttpBytesReceived<'a> { pub byte_size: usize, pub http_path: &'a str, @@ -64,6 +68,7 @@ impl InternalEvent for HttpBytesReceived<'_> { } #[derive(Debug)] +#[internal_event] pub struct HttpEventsReceived<'a> { pub count: usize, pub byte_size: JsonSize, @@ -99,6 +104,7 @@ impl InternalEvent for HttpEventsReceived<'_> { #[cfg(feature = "sources-utils-http")] #[derive(Debug)] +#[internal_event] pub struct HttpBadRequest<'a> { code: u16, error_code: String, @@ -139,6 +145,7 @@ impl InternalEvent for HttpBadRequest<'_> { } #[derive(Debug)] +#[internal_event] pub struct HttpDecompressError<'a> { pub error: &'a dyn Error, pub encoding: &'a str, @@ -165,6 +172,7 @@ impl InternalEvent for HttpDecompressError<'_> { } } +#[internal_event] pub struct HttpInternalError<'a> { pub message: &'a str, } diff --git a/src/internal_events/http_client.rs b/src/internal_events/http_client.rs index 4db92d38cc3e7..485109211a98f 100644 --- a/src/internal_events/http_client.rs +++ b/src/internal_events/http_client.rs @@ -6,9 +6,11 @@ use http::{ }; use hyper::{Error, body::HttpBody}; use metrics::{counter, histogram}; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; #[derive(Debug)] +#[internal_event] pub struct AboutToSendHttpRequest<'a, T> { pub request: &'a Request, } @@ -44,6 +46,7 @@ impl InternalEvent for AboutToSendHttpRequest<'_, T> { } #[derive(Debug)] +#[internal_event] pub struct GotHttpResponse<'a, T> { pub response: &'a Response, pub roundtrip: Duration, @@ -73,6 +76,7 @@ impl InternalEvent for GotHttpResponse<'_, T> { } #[derive(Debug)] +#[internal_event] pub struct GotHttpWarning<'a> { pub error: &'a Error, pub roundtrip: Duration, diff --git a/src/internal_events/http_client_source.rs b/src/internal_events/http_client_source.rs index 4bd19f156ff1c..00c6c43cb509a 100644 --- a/src/internal_events/http_client_source.rs +++ b/src/internal_events/http_client_source.rs @@ -1,6 +1,7 @@ #![allow(dead_code)] // TODO requires optional feature compilation use metrics::counter; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, @@ -9,6 +10,7 @@ use vector_lib::{ use super::prelude::http_error_code; #[derive(Debug)] +#[internal_event] pub struct HttpClientEventsReceived { pub byte_size: JsonSize, pub count: usize, @@ -37,6 +39,7 @@ impl InternalEvent for HttpClientEventsReceived { } #[derive(Debug)] +#[internal_event] pub struct HttpClientHttpResponseError { pub code: hyper::StatusCode, pub url: String, @@ -64,6 +67,7 @@ impl InternalEvent for HttpClientHttpResponseError { } #[derive(Debug)] +#[internal_event] pub struct HttpClientHttpError { pub error: crate::Error, pub url: String, diff --git a/src/internal_events/influxdb.rs b/src/internal_events/influxdb.rs index 61c3c29d3bd24..3d1640f784ded 100644 --- a/src/internal_events/influxdb.rs +++ b/src/internal_events/influxdb.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct InfluxdbEncodingError { pub error_message: &'static str, diff --git a/src/internal_events/internal_logs.rs b/src/internal_events/internal_logs.rs index afc0d32f8ad2d..ffbbe73e1bf32 100644 --- a/src/internal_events/internal_logs.rs +++ b/src/internal_events/internal_logs.rs @@ -1,7 +1,9 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::{internal_event::InternalEvent, json_size::JsonSize}; #[derive(Debug)] +#[internal_event] pub struct InternalLogsBytesReceived { pub byte_size: usize, } @@ -18,6 +20,7 @@ impl InternalEvent for InternalLogsBytesReceived { } #[derive(Debug)] +#[internal_event] pub struct InternalLogsEventsReceived { pub byte_size: JsonSize, pub count: usize, diff --git a/src/internal_events/journald.rs b/src/internal_events/journald.rs index 18ee29093c7c6..dc2c0417978ec 100644 --- a/src/internal_events/journald.rs +++ b/src/internal_events/journald.rs @@ -1,10 +1,12 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::{ codecs::decoding::BoxedFramingError, internal_event::{InternalEvent, error_stage, error_type}, }; #[derive(Debug)] +#[internal_event] pub struct JournaldInvalidRecordError { pub error: serde_json::Error, pub text: String, @@ -30,6 +32,7 @@ impl InternalEvent for JournaldInvalidRecordError { } #[derive(Debug)] +#[internal_event] pub struct JournaldStartJournalctlError { pub error: crate::Error, } @@ -53,6 +56,7 @@ impl InternalEvent for JournaldStartJournalctlError { } #[derive(Debug)] +#[internal_event] pub struct JournaldReadError { pub error: BoxedFramingError, } @@ -76,6 +80,7 @@ impl InternalEvent for JournaldReadError { } #[derive(Debug)] +#[internal_event] pub struct JournaldCheckpointSetError { pub error: std::io::Error, pub filename: String, @@ -101,6 +106,7 @@ impl InternalEvent for JournaldCheckpointSetError { } #[derive(Debug)] +#[internal_event] pub struct JournaldCheckpointFileOpenError { pub error: std::io::Error, pub path: String, diff --git a/src/internal_events/kafka.rs b/src/internal_events/kafka.rs index 8f8098b66361d..dcdf00ed87c97 100644 --- a/src/internal_events/kafka.rs +++ b/src/internal_events/kafka.rs @@ -1,6 +1,7 @@ #![allow(dead_code)] // TODO requires optional feature compilation use metrics::{counter, gauge}; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, @@ -8,6 +9,7 @@ use vector_lib::{ use vrl::path::OwnedTargetPath; #[derive(Debug)] +#[internal_event] pub struct KafkaBytesReceived<'a> { pub byte_size: usize, pub protocol: &'static str, @@ -35,6 +37,7 @@ impl InternalEvent for KafkaBytesReceived<'_> { } #[derive(Debug)] +#[internal_event] pub struct KafkaEventsReceived<'a> { pub byte_size: JsonSize, pub count: usize, @@ -67,6 +70,7 @@ impl InternalEvent for KafkaEventsReceived<'_> { } #[derive(Debug)] +#[internal_event] pub struct KafkaOffsetUpdateError { pub error: rdkafka::error::KafkaError, } @@ -92,6 +96,7 @@ impl InternalEvent for KafkaOffsetUpdateError { } #[derive(Debug)] +#[internal_event] pub struct KafkaReadError { pub error: rdkafka::error::KafkaError, } @@ -117,6 +122,7 @@ impl InternalEvent for KafkaReadError { } #[derive(Debug)] +#[internal_event] pub struct KafkaStatisticsReceived<'a> { pub statistics: &'a rdkafka::Statistics, pub expose_lag_metrics: bool, @@ -152,6 +158,7 @@ impl InternalEvent for KafkaStatisticsReceived<'_> { } } +#[internal_event] pub struct KafkaHeaderExtractionError<'a> { pub header_field: &'a OwnedTargetPath, } diff --git a/src/internal_events/kubernetes_logs.rs b/src/internal_events/kubernetes_logs.rs index e697be5c0f0aa..fa4bd4b4d9f98 100644 --- a/src/internal_events/kubernetes_logs.rs +++ b/src/internal_events/kubernetes_logs.rs @@ -1,4 +1,5 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::{ internal_event::{ ComponentEventsDropped, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -10,6 +11,7 @@ use vrl::core::Value; use crate::event::Event; #[derive(Debug)] +#[internal_event] pub struct KubernetesLogsEventsReceived<'a> { pub file: &'a str, pub byte_size: JsonSize, @@ -60,6 +62,7 @@ impl InternalEvent for KubernetesLogsEventsReceived<'_> { const ANNOTATION_FAILED: &str = "annotation_failed"; #[derive(Debug)] +#[internal_event] pub struct KubernetesLogsEventAnnotationError<'a> { pub event: &'a Event, } @@ -85,6 +88,7 @@ impl InternalEvent for KubernetesLogsEventAnnotationError<'_> { } #[derive(Debug)] +#[internal_event] pub(crate) struct KubernetesLogsEventNamespaceAnnotationError<'a> { pub event: &'a Event, } @@ -111,6 +115,7 @@ impl InternalEvent for KubernetesLogsEventNamespaceAnnotationError<'_> { } #[derive(Debug)] +#[internal_event] pub(crate) struct KubernetesLogsEventNodeAnnotationError<'a> { pub event: &'a Event, } @@ -137,6 +142,7 @@ impl InternalEvent for KubernetesLogsEventNodeAnnotationError<'_> { } #[derive(Debug)] +#[internal_event] pub struct KubernetesLogsFormatPickerEdgeCase { pub what: &'static str, } @@ -152,6 +158,7 @@ impl InternalEvent for KubernetesLogsFormatPickerEdgeCase { } #[derive(Debug)] +#[internal_event] pub struct KubernetesLogsDockerFormatParseError<'a> { pub error: &'a dyn std::error::Error, } @@ -178,6 +185,7 @@ impl InternalEvent for KubernetesLogsDockerFormatParseError<'_> { const KUBERNETES_LIFECYCLE: &str = "kubernetes_lifecycle"; #[derive(Debug)] +#[internal_event] pub struct KubernetesLifecycleError { pub message: &'static str, pub error: E, @@ -209,6 +217,7 @@ impl InternalEvent for KubernetesLifecycleError { } #[derive(Debug)] +#[internal_event] pub struct KubernetesMergedLineTooBigError<'a> { pub event: &'a Value, pub configured_limit: usize, diff --git a/src/internal_events/log_to_metric.rs b/src/internal_events/log_to_metric.rs index 0f7a000e364d4..2bc9dc96eb0c9 100644 --- a/src/internal_events/log_to_metric.rs +++ b/src/internal_events/log_to_metric.rs @@ -1,10 +1,12 @@ use std::num::ParseFloatError; use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] pub struct LogToMetricFieldNullError<'a> { pub field: &'a str, } @@ -33,6 +35,7 @@ impl InternalEvent for LogToMetricFieldNullError<'_> { } } +#[internal_event] pub struct LogToMetricParseFloatError<'a> { pub field: &'a str, pub error: ParseFloatError, @@ -64,6 +67,7 @@ impl InternalEvent for LogToMetricParseFloatError<'_> { } // Metric Metadata Events and Errors +#[internal_event] pub struct MetricMetadataInvalidFieldValueError<'a> { pub field: &'a str, pub field_value: &'a str, @@ -94,6 +98,7 @@ impl InternalEvent for MetricMetadataInvalidFieldValueError<'_> { } } +#[internal_event] pub struct MetricMetadataParseError<'a> { pub field: &'a str, pub kind: &'a str, @@ -123,6 +128,7 @@ impl InternalEvent for MetricMetadataParseError<'_> { } } +#[internal_event] pub struct MetricMetadataMetricDetailsNotFoundError {} impl InternalEvent for MetricMetadataMetricDetailsNotFoundError { diff --git a/src/internal_events/logplex.rs b/src/internal_events/logplex.rs index a5bdf19566079..43bc7e7d178b4 100644 --- a/src/internal_events/logplex.rs +++ b/src/internal_events/logplex.rs @@ -1,9 +1,11 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use super::prelude::io_error_code; #[derive(Debug)] +#[internal_event] pub struct HerokuLogplexRequestReceived<'a> { pub msg_count: usize, pub frame_id: &'a str, @@ -23,6 +25,7 @@ impl InternalEvent for HerokuLogplexRequestReceived<'_> { } #[derive(Debug)] +#[internal_event] pub struct HerokuLogplexRequestReadError { pub error: std::io::Error, } diff --git a/src/internal_events/loki.rs b/src/internal_events/loki.rs index 8872c1084f59f..550a247051087 100644 --- a/src/internal_events/loki.rs +++ b/src/internal_events/loki.rs @@ -1,9 +1,11 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, INTENTIONAL, InternalEvent, error_stage, error_type, }; #[derive(Debug)] +#[internal_event] pub struct LokiEventUnlabeledError; impl InternalEvent for LokiEventUnlabeledError { @@ -27,6 +29,7 @@ impl InternalEvent for LokiEventUnlabeledError { } #[derive(Debug)] +#[internal_event] pub struct LokiOutOfOrderEventDroppedError { pub count: usize, } @@ -59,6 +62,7 @@ impl InternalEvent for LokiOutOfOrderEventDroppedError { } #[derive(Debug)] +#[internal_event] pub struct LokiOutOfOrderEventRewritten { pub count: usize, } @@ -76,6 +80,7 @@ impl InternalEvent for LokiOutOfOrderEventRewritten { } #[derive(Debug)] +#[internal_event] pub struct LokiTimestampNonParsableEventsDropped; impl InternalEvent for LokiTimestampNonParsableEventsDropped { diff --git a/src/internal_events/lua.rs b/src/internal_events/lua.rs index fba5eede5d0d6..7a2d92ca0780a 100644 --- a/src/internal_events/lua.rs +++ b/src/internal_events/lua.rs @@ -1,4 +1,5 @@ use metrics::{counter, gauge}; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; @@ -6,6 +7,7 @@ use vector_lib::internal_event::{ use crate::transforms::lua::v2::BuildError; #[derive(Debug)] +#[internal_event] pub struct LuaGcTriggered { pub used_memory: usize, } @@ -17,6 +19,7 @@ impl InternalEvent for LuaGcTriggered { } #[derive(Debug)] +#[internal_event] pub struct LuaScriptError { pub error: mlua::Error, } @@ -46,6 +49,7 @@ impl InternalEvent for LuaScriptError { } #[derive(Debug)] +#[internal_event] pub struct LuaBuildError { pub error: BuildError, } diff --git a/src/internal_events/metric_to_log.rs b/src/internal_events/metric_to_log.rs index 2bfa88984f1c6..3009954bc944d 100644 --- a/src/internal_events/metric_to_log.rs +++ b/src/internal_events/metric_to_log.rs @@ -1,9 +1,11 @@ use metrics::counter; use serde_json::Error; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct MetricToLogSerializeError { pub error: Error, diff --git a/src/internal_events/mongodb_metrics.rs b/src/internal_events/mongodb_metrics.rs index cce12530314c7..d0a87cb0b0168 100644 --- a/src/internal_events/mongodb_metrics.rs +++ b/src/internal_events/mongodb_metrics.rs @@ -1,10 +1,12 @@ use metrics::counter; use mongodb::{bson, error::Error as MongoError}; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, }; +#[internal_event] #[derive(Debug)] pub struct MongoDbMetricsEventsReceived<'a> { pub count: usize, @@ -34,6 +36,7 @@ impl InternalEvent for MongoDbMetricsEventsReceived<'_> { } } +#[internal_event] pub struct MongoDbMetricsRequestError<'a> { pub error: MongoError, pub endpoint: &'a str, @@ -58,6 +61,7 @@ impl InternalEvent for MongoDbMetricsRequestError<'_> { } } +#[internal_event] pub struct MongoDbMetricsBsonParseError<'a> { pub error: bson::de::Error, pub endpoint: &'a str, diff --git a/src/internal_events/mqtt.rs b/src/internal_events/mqtt.rs index ac736e308c121..9f3aa2af43634 100644 --- a/src/internal_events/mqtt.rs +++ b/src/internal_events/mqtt.rs @@ -2,9 +2,11 @@ use std::fmt::Debug; use metrics::counter; use rumqttc::ConnectionError; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; #[derive(Debug)] +#[internal_event] pub struct MqttConnectionError { pub error: ConnectionError, } @@ -27,8 +29,4 @@ impl InternalEvent for MqttConnectionError { ) .increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("MqttConnectionError") - } } diff --git a/src/internal_events/nginx_metrics.rs b/src/internal_events/nginx_metrics.rs index f31e8ca24d7e2..2d5d1a0aaf699 100644 --- a/src/internal_events/nginx_metrics.rs +++ b/src/internal_events/nginx_metrics.rs @@ -1,4 +1,5 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::{ internal_event::{InternalEvent, error_stage, error_type}, json_size::JsonSize, @@ -6,6 +7,7 @@ use vector_lib::{ use crate::sources::nginx_metrics::parser::ParseError; +#[internal_event] #[derive(Debug)] pub struct NginxMetricsEventsReceived<'a> { pub byte_size: JsonSize, @@ -34,6 +36,7 @@ impl InternalEvent for NginxMetricsEventsReceived<'_> { } } +#[internal_event] pub struct NginxMetricsRequestError<'a> { pub error: crate::Error, pub endpoint: &'a str, @@ -59,6 +62,7 @@ impl InternalEvent for NginxMetricsRequestError<'_> { } } +#[internal_event] pub(crate) struct NginxMetricsStubStatusParseError<'a> { pub error: ParseError, pub endpoint: &'a str, diff --git a/src/internal_events/open.rs b/src/internal_events/open.rs index ccd9d8cf5411a..707955f3f2d35 100644 --- a/src/internal_events/open.rs +++ b/src/internal_events/open.rs @@ -7,8 +7,10 @@ use std::{ }; use metrics::gauge; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; +#[internal_event] #[derive(Debug)] pub struct ConnectionOpen { pub count: usize, @@ -20,6 +22,7 @@ impl InternalEvent for ConnectionOpen { } } +#[internal_event] #[derive(Debug)] pub struct EndpointsActive { pub count: usize, diff --git a/src/internal_events/parser.rs b/src/internal_events/parser.rs index 965e39669fa43..3427f2eadb6e9 100644 --- a/src/internal_events/parser.rs +++ b/src/internal_events/parser.rs @@ -3,6 +3,7 @@ use std::borrow::Cow; use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; @@ -20,6 +21,7 @@ fn truncate_string_at(s: &str, maxlen: usize) -> Cow<'_, str> { } } +#[internal_event] #[derive(Debug)] pub struct ParserMatchError<'a> { pub value: &'a [u8], @@ -50,6 +52,7 @@ pub const DROP_EVENT: bool = true; #[allow(dead_code)] pub const RETAIN_EVENT: bool = false; +#[internal_event] #[derive(Debug)] pub struct ParserMissingFieldError<'a, const DROP_EVENT: bool> { pub field: &'a str, @@ -81,6 +84,7 @@ impl InternalEvent for ParserMissingFieldError<'_, DROP_ } } +#[internal_event] #[derive(Debug)] pub struct ParserConversionError<'a> { pub name: &'a str, diff --git a/src/internal_events/postgresql_metrics.rs b/src/internal_events/postgresql_metrics.rs index 86d17b1b9ea39..d430f34a84190 100644 --- a/src/internal_events/postgresql_metrics.rs +++ b/src/internal_events/postgresql_metrics.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct PostgresqlMetricsCollectError<'a> { pub error: String, diff --git a/src/internal_events/process.rs b/src/internal_events/process.rs index 15c16c1cf9d25..7bdd6449ed443 100644 --- a/src/internal_events/process.rs +++ b/src/internal_events/process.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use crate::{built_info, config}; +#[internal_event] #[derive(Debug)] pub struct VectorStarted; @@ -20,6 +22,7 @@ impl InternalEvent for VectorStarted { } } +#[internal_event] #[derive(Debug)] pub struct VectorReloaded<'a> { pub config_paths: &'a [config::ConfigPath], @@ -36,6 +39,7 @@ impl InternalEvent for VectorReloaded<'_> { } } +#[internal_event] #[derive(Debug)] pub struct VectorStopped; @@ -49,6 +53,7 @@ impl InternalEvent for VectorStopped { } } +#[internal_event] #[derive(Debug)] pub struct VectorQuit; @@ -62,6 +67,7 @@ impl InternalEvent for VectorQuit { } } +#[internal_event] #[derive(Debug)] pub struct VectorReloadError; @@ -84,6 +90,7 @@ impl InternalEvent for VectorReloadError { } } +#[internal_event] #[derive(Debug)] pub struct VectorConfigLoadError; @@ -106,6 +113,7 @@ impl InternalEvent for VectorConfigLoadError { } } +#[internal_event] #[derive(Debug)] pub struct VectorRecoveryError; diff --git a/src/internal_events/prometheus.rs b/src/internal_events/prometheus.rs index 554a5291c0fdf..6c5e268d39eaa 100644 --- a/src/internal_events/prometheus.rs +++ b/src/internal_events/prometheus.rs @@ -4,6 +4,7 @@ use std::borrow::Cow; use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; @@ -11,6 +12,7 @@ use vector_lib::internal_event::{ use vector_lib::prometheus::parser::ParserError; #[cfg(feature = "sources-prometheus-scrape")] +#[internal_event] #[derive(Debug)] pub struct PrometheusParseError<'a> { pub error: ParserError, @@ -44,6 +46,7 @@ impl InternalEvent for PrometheusParseError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct PrometheusRemoteWriteParseError { pub error: prost::DecodeError, @@ -67,6 +70,7 @@ impl InternalEvent for PrometheusRemoteWriteParseError { } } +#[internal_event] #[derive(Debug)] pub struct PrometheusNormalizationError; diff --git a/src/internal_events/pulsar.rs b/src/internal_events/pulsar.rs index 838a2aadd995e..df9d00f7c678f 100644 --- a/src/internal_events/pulsar.rs +++ b/src/internal_events/pulsar.rs @@ -3,10 +3,12 @@ #[cfg(feature = "sources-pulsar")] use metrics::Counter; use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct PulsarSendingError { pub count: usize, @@ -36,6 +38,7 @@ impl InternalEvent for PulsarSendingError { } } +#[internal_event] pub struct PulsarPropertyExtractionError { pub property_field: F, } diff --git a/src/internal_events/redis.rs b/src/internal_events/redis.rs index 3e4ef64020e2b..c766ed4482668 100644 --- a/src/internal_events/redis.rs +++ b/src/internal_events/redis.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; +#[internal_event] #[derive(Debug)] pub struct RedisReceiveEventError { error: redis::RedisError, diff --git a/src/internal_events/reduce.rs b/src/internal_events/reduce.rs index 7b9b2f13806a2..c3955a8dd411a 100644 --- a/src/internal_events/reduce.rs +++ b/src/internal_events/reduce.rs @@ -1,7 +1,9 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use vrl::{path::PathParseError, value::KeyString}; +#[internal_event] #[derive(Debug)] pub struct ReduceStaleEventFlushed; @@ -11,6 +13,7 @@ impl InternalEvent for ReduceStaleEventFlushed { } } +#[internal_event] #[derive(Debug)] pub struct ReduceAddEventError { pub error: PathParseError, diff --git a/src/internal_events/remap.rs b/src/internal_events/remap.rs index 39657d1c00571..a0a5d7d2c2211 100644 --- a/src/internal_events/remap.rs +++ b/src/internal_events/remap.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, INTENTIONAL, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] #[derive(Debug)] pub struct RemapMappingError { /// If set to true, the remap transform has dropped the event after a failed @@ -35,6 +37,7 @@ impl InternalEvent for RemapMappingError { } } +#[internal_event] #[derive(Debug)] pub struct RemapMappingAbort { /// If set to true, the remap transform has dropped the event after an abort diff --git a/src/internal_events/sample.rs b/src/internal_events/sample.rs index c502272908115..062ae3f4508cf 100644 --- a/src/internal_events/sample.rs +++ b/src/internal_events/sample.rs @@ -1,5 +1,7 @@ +use vector_config::internal_event; use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; +#[internal_event] #[derive(Debug)] pub struct SampleEventDiscarded; diff --git a/src/internal_events/sematext_metrics.rs b/src/internal_events/sematext_metrics.rs index 1e43dc94f602f..5126d9efff085 100644 --- a/src/internal_events/sematext_metrics.rs +++ b/src/internal_events/sematext_metrics.rs @@ -1,10 +1,12 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use crate::event::metric::Metric; +#[internal_event] #[derive(Debug)] pub struct SematextMetricsInvalidMetricError<'a> { pub metric: &'a Metric, @@ -34,6 +36,7 @@ impl InternalEvent for SematextMetricsInvalidMetricError<'_> { } } +#[internal_event] #[derive(Debug)] pub struct SematextMetricsEncodeEventError { pub error: E, diff --git a/src/internal_events/socket.rs b/src/internal_events/socket.rs index 46bf642305ec5..58d49a0335725 100644 --- a/src/internal_events/socket.rs +++ b/src/internal_events/socket.rs @@ -1,6 +1,7 @@ use std::net::Ipv4Addr; use metrics::{counter, histogram}; +use vector_config::internal_event; use vector_lib::{ internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, @@ -25,7 +26,9 @@ impl SocketMode { } } } + #[derive(Debug)] +#[internal_event] pub struct SocketBytesReceived { pub mode: SocketMode, pub byte_size: usize, @@ -49,6 +52,7 @@ impl InternalEvent for SocketBytesReceived { } #[derive(Debug)] +#[internal_event] pub struct SocketEventsReceived { pub mode: SocketMode, pub byte_size: JsonSize, @@ -72,6 +76,7 @@ impl InternalEvent for SocketEventsReceived { } #[derive(Debug)] +#[internal_event] pub struct SocketBytesSent { pub mode: SocketMode, pub byte_size: usize, @@ -94,6 +99,7 @@ impl InternalEvent for SocketBytesSent { } #[derive(Debug)] +#[internal_event] pub struct SocketEventsSent { pub mode: SocketMode, pub count: u64, @@ -110,6 +116,7 @@ impl InternalEvent for SocketEventsSent { } #[derive(Debug)] +#[internal_event] pub struct SocketBindError { pub mode: SocketMode, pub error: E, @@ -139,6 +146,7 @@ impl InternalEvent for SocketBindError { } #[derive(Debug)] +#[internal_event] pub struct SocketMulticastGroupJoinError { pub error: E, pub group_addr: Ipv4Addr, @@ -177,6 +185,7 @@ impl InternalEvent for SocketMulticastGroupJoinError { } #[derive(Debug)] +#[internal_event] pub struct SocketReceiveError { pub mode: SocketMode, pub error: E, @@ -206,6 +215,7 @@ impl InternalEvent for SocketReceiveError { } #[derive(Debug)] +#[internal_event] pub struct SocketSendError { pub mode: SocketMode, pub error: E, diff --git a/src/internal_events/splunk_hec.rs b/src/internal_events/splunk_hec.rs index 366287f068f4f..dd0424bb0d637 100644 --- a/src/internal_events/splunk_hec.rs +++ b/src/internal_events/splunk_hec.rs @@ -9,6 +9,7 @@ pub use self::source::*; mod sink { use metrics::{counter, gauge}; use serde_json::Error; + use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; @@ -18,6 +19,7 @@ mod sink { sinks::splunk_hec::common::acknowledgements::HecAckApiError, }; + #[internal_event] #[derive(Debug)] pub struct SplunkEventEncodeError { pub error: vector_lib::Error, @@ -45,6 +47,7 @@ mod sink { } } + #[internal_event] #[derive(Debug)] pub(crate) struct SplunkInvalidMetricReceivedError<'a> { pub value: &'a MetricValue, @@ -78,6 +81,7 @@ mod sink { } } + #[internal_event] #[derive(Debug)] pub struct SplunkResponseParseError { pub error: Error, @@ -103,6 +107,7 @@ mod sink { } } + #[internal_event] #[derive(Debug)] pub struct SplunkIndexerAcknowledgementAPIError { pub message: &'static str, @@ -129,6 +134,7 @@ mod sink { } } + #[internal_event] #[derive(Debug)] pub struct SplunkIndexerAcknowledgementUnavailableError { pub error: E, @@ -154,6 +160,7 @@ mod sink { } } + #[internal_event] pub struct SplunkIndexerAcknowledgementAckAdded; impl InternalEvent for SplunkIndexerAcknowledgementAckAdded { @@ -162,6 +169,7 @@ mod sink { } } + #[internal_event] pub struct SplunkIndexerAcknowledgementAcksRemoved { pub count: f64, } @@ -172,6 +180,7 @@ mod sink { } } + #[internal_event] pub struct SplunkEventTimestampInvalidType<'a> { pub r#type: &'a str, } @@ -187,6 +196,7 @@ mod sink { } } + #[internal_event] pub struct SplunkEventTimestampMissing; impl InternalEvent for SplunkEventTimestampMissing { @@ -202,10 +212,12 @@ mod sink { #[cfg(feature = "sources-splunk_hec")] mod source { use metrics::counter; + use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use crate::sources::splunk_hec::ApiError; + #[internal_event] #[derive(Debug)] pub struct SplunkHecRequestBodyInvalidError { pub error: std::io::Error, @@ -231,6 +243,7 @@ mod source { } } + #[internal_event] #[derive(Debug)] pub struct SplunkHecRequestError { pub(crate) error: ApiError, diff --git a/src/internal_events/statsd_sink.rs b/src/internal_events/statsd_sink.rs index 732f151602363..57d4c534c549d 100644 --- a/src/internal_events/statsd_sink.rs +++ b/src/internal_events/statsd_sink.rs @@ -1,10 +1,12 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; use crate::event::metric::{MetricKind, MetricValue}; +#[internal_event] #[derive(Debug)] pub struct StatsdInvalidMetricError<'a> { pub value: &'a MetricValue, diff --git a/src/internal_events/tag_cardinality_limit.rs b/src/internal_events/tag_cardinality_limit.rs index 9db97e39f44b9..4eecc9e055063 100644 --- a/src/internal_events/tag_cardinality_limit.rs +++ b/src/internal_events/tag_cardinality_limit.rs @@ -1,6 +1,8 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; +#[internal_event] pub struct TagCardinalityLimitRejectingEvent<'a> { pub metric_name: &'a str, pub tag_key: &'a str, @@ -25,6 +27,7 @@ impl InternalEvent for TagCardinalityLimitRejectingEvent<'_> { } } +#[internal_event] pub struct TagCardinalityLimitRejectingTag<'a> { pub metric_name: &'a str, pub tag_key: &'a str, @@ -44,6 +47,7 @@ impl InternalEvent for TagCardinalityLimitRejectingTag<'_> { } } +#[internal_event] pub struct TagCardinalityValueLimitReached<'a> { pub key: &'a str, } diff --git a/src/internal_events/tcp.rs b/src/internal_events/tcp.rs index 5ff074a158172..b7a784fa61560 100644 --- a/src/internal_events/tcp.rs +++ b/src/internal_events/tcp.rs @@ -1,10 +1,12 @@ use std::net::SocketAddr; use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; use crate::{internal_events::SocketOutgoingConnectionError, tls::TlsError}; +#[internal_event] #[derive(Debug)] pub struct TcpSocketConnectionEstablished { pub peer_addr: Option, @@ -21,6 +23,7 @@ impl InternalEvent for TcpSocketConnectionEstablished { } } +#[internal_event] #[derive(Debug)] pub struct TcpSocketOutgoingConnectionError { pub error: E, @@ -34,6 +37,7 @@ impl InternalEvent for TcpSocketOutgoingConnectionError } } +#[internal_event] #[derive(Debug)] pub struct TcpSocketConnectionShutdown; @@ -45,6 +49,7 @@ impl InternalEvent for TcpSocketConnectionShutdown { } #[cfg(all(unix, feature = "sources-dnstap"))] +#[internal_event] #[derive(Debug)] pub struct TcpSocketError<'a, E> { pub(crate) error: &'a E, @@ -71,6 +76,7 @@ impl InternalEvent for TcpSocketError<'_, E> { } } +#[internal_event] #[derive(Debug)] pub struct TcpSocketTlsConnectionError { pub error: TlsError, @@ -114,6 +120,7 @@ impl InternalEvent for TcpSocketTlsConnectionError { } } +#[internal_event] #[derive(Debug)] pub struct TcpSendAckError { pub error: std::io::Error, @@ -140,6 +147,7 @@ impl InternalEvent for TcpSendAckError { } } +#[internal_event] #[derive(Debug)] pub struct TcpBytesReceived { pub byte_size: usize, diff --git a/src/internal_events/template.rs b/src/internal_events/template.rs index 4577d888e97a2..d87810f061e40 100644 --- a/src/internal_events/template.rs +++ b/src/internal_events/template.rs @@ -1,8 +1,10 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; +#[internal_event] pub struct TemplateRenderingError<'a> { pub field: Option<&'a str>, pub drop_event: bool, diff --git a/src/internal_events/throttle.rs b/src/internal_events/throttle.rs index 5999033d4b1fe..900c61eee4b44 100644 --- a/src/internal_events/throttle.rs +++ b/src/internal_events/throttle.rs @@ -1,7 +1,9 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent}; #[derive(Debug)] +#[internal_event] pub(crate) struct ThrottleEventDiscarded { pub key: String, pub emit_events_discarded_per_key: bool, diff --git a/src/internal_events/udp.rs b/src/internal_events/udp.rs index 7ad19dd22cbc0..f2b7a95cb8d2d 100644 --- a/src/internal_events/udp.rs +++ b/src/internal_events/udp.rs @@ -1,4 +1,5 @@ use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; @@ -7,6 +8,7 @@ use crate::internal_events::SocketOutgoingConnectionError; // TODO: Get rid of this. UDP is connectionless, so there's no "successful" connect event, only // successfully binding a socket that can be used for receiving. +#[internal_event] #[derive(Debug)] pub struct UdpSocketConnectionEstablished; @@ -19,6 +21,7 @@ impl InternalEvent for UdpSocketConnectionEstablished { // TODO: Get rid of this. UDP is connectionless, so there's no "unsuccessful" connect event, only // unsuccessfully binding a socket that can be used for receiving. +#[internal_event] pub struct UdpSocketOutgoingConnectionError { pub error: E, } @@ -31,6 +34,7 @@ impl InternalEvent for UdpSocketOutgoingConnectionError } } +#[internal_event] #[derive(Debug)] pub struct UdpSendIncompleteError { pub data_size: usize, @@ -62,6 +66,7 @@ impl InternalEvent for UdpSendIncompleteError { } } +#[internal_event] #[derive(Debug)] pub struct UdpChunkingError { pub error: vector_common::Error, diff --git a/src/internal_events/unix.rs b/src/internal_events/unix.rs index ea91cd483bdd9..65c85e97176b9 100644 --- a/src/internal_events/unix.rs +++ b/src/internal_events/unix.rs @@ -3,6 +3,7 @@ use std::{io::Error, path::Path}; use metrics::counter; +use vector_config::internal_event; use vector_lib::internal_event::{ ComponentEventsDropped, InternalEvent, UNINTENTIONAL, error_stage, error_type, }; @@ -10,6 +11,7 @@ use vector_lib::internal_event::{ use crate::internal_events::SocketOutgoingConnectionError; #[derive(Debug)] +#[internal_event] pub struct UnixSocketConnectionEstablished<'a> { pub path: &'a std::path::Path, } @@ -22,6 +24,7 @@ impl InternalEvent for UnixSocketConnectionEstablished<'_> { } #[derive(Debug)] +#[internal_event] pub struct UnixSocketOutgoingConnectionError { pub error: E, } @@ -39,6 +42,7 @@ impl InternalEvent for UnixSocketOutgoingConnectionError { pub(crate) error: &'a E, pub path: &'a std::path::Path, @@ -68,6 +72,7 @@ impl InternalEvent for UnixSocketError<'_, E> { } #[derive(Debug)] +#[internal_event] pub struct UnixSocketSendError<'a, E> { pub(crate) error: &'a E, pub path: &'a std::path::Path, @@ -96,6 +101,7 @@ impl InternalEvent for UnixSocketSendError<'_, E> { } #[derive(Debug)] +#[internal_event] pub struct UnixSendIncompleteError { pub data_size: usize, pub sent: usize, @@ -125,6 +131,7 @@ impl InternalEvent for UnixSendIncompleteError { } #[derive(Debug)] +#[internal_event] pub struct UnixSocketFileDeleteError<'a> { pub path: &'a Path, pub error: Error, diff --git a/src/internal_events/websocket.rs b/src/internal_events/websocket.rs index 28fc844680cef..0a8ae077b0116 100644 --- a/src/internal_events/websocket.rs +++ b/src/internal_events/websocket.rs @@ -11,11 +11,13 @@ use vector_common::{ internal_event::{error_stage, error_type}, json_size::JsonSize, }; +use vector_config::internal_event; use vector_lib::internal_event::InternalEvent; pub const PROTOCOL: &str = "websocket"; #[derive(Debug)] +#[internal_event] pub struct WebSocketConnectionEstablished; impl InternalEvent for WebSocketConnectionEstablished { @@ -23,13 +25,10 @@ impl InternalEvent for WebSocketConnectionEstablished { debug!(message = "Connected."); counter!("connection_established_total").increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketConnectionEstablished") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketConnectionFailedError { pub error: Box, } @@ -52,13 +51,10 @@ impl InternalEvent for WebSocketConnectionFailedError { ) .increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketConnectionFailedError") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketConnectionShutdown; impl InternalEvent for WebSocketConnectionShutdown { @@ -66,13 +62,10 @@ impl InternalEvent for WebSocketConnectionShutdown { warn!(message = "Closed by the server."); counter!("connection_shutdown_total").increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketConnectionShutdown") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketConnectionError { pub error: tokio_tungstenite::tungstenite::Error, } @@ -96,10 +89,6 @@ impl InternalEvent for WebSocketConnectionError { ) .increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketConnectionError") - } } #[allow(dead_code)] @@ -120,6 +109,7 @@ impl Display for WebSocketKind { } #[derive(Debug)] +#[internal_event] pub struct WebSocketBytesReceived<'a> { pub byte_size: usize, pub url: &'a str, @@ -147,6 +137,7 @@ impl InternalEvent for WebSocketBytesReceived<'_> { } #[derive(Debug)] +#[internal_event] pub struct WebSocketMessageReceived<'a> { pub count: usize, pub byte_size: JsonSize, @@ -183,13 +174,10 @@ impl InternalEvent for WebSocketMessageReceived<'_> { ); counter.increment(self.byte_size.get() as u64); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketMessageReceived") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketReceiveError<'a> { pub error: &'a TungsteniteError, } @@ -213,13 +201,10 @@ impl InternalEvent for WebSocketReceiveError<'_> { ) .increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketReceiveError") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketSendError<'a> { pub error: &'a TungsteniteError, } @@ -242,8 +227,4 @@ impl InternalEvent for WebSocketSendError<'_> { ) .increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketSendError") - } } diff --git a/src/internal_events/websocket_server.rs b/src/internal_events/websocket_server.rs index e15cbf515b00c..24ed66f259264 100644 --- a/src/internal_events/websocket_server.rs +++ b/src/internal_events/websocket_server.rs @@ -1,9 +1,11 @@ use std::{error::Error, fmt::Debug}; use metrics::{counter, gauge}; +use vector_config::internal_event; use vector_lib::internal_event::{InternalEvent, error_stage, error_type}; #[derive(Debug)] +#[internal_event] pub struct WebSocketListenerConnectionEstablished { pub client_count: usize, pub extra_tags: Vec<(String, String)>, @@ -20,13 +22,10 @@ impl InternalEvent for WebSocketListenerConnectionEstablished { counter!("connection_established_total", &self.extra_tags).increment(1); gauge!("active_clients", &self.extra_tags).set(self.client_count as f64); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketListenerConnectionEstablished") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketListenerConnectionFailedError { pub error: Box, pub extra_tags: Vec<(String, String)>, @@ -55,13 +54,10 @@ impl InternalEvent for WebSocketListenerConnectionFailedError { // ## skip check-validity-events ## counter!("component_errors_total", &all_tags).increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WsListenerConnectionFailed") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketListenerConnectionShutdown { pub client_count: usize, pub extra_tags: Vec<(String, String)>, @@ -78,13 +74,10 @@ impl InternalEvent for WebSocketListenerConnectionShutdown { counter!("connection_shutdown_total", &self.extra_tags).increment(1); gauge!("active_clients", &self.extra_tags).set(self.client_count as f64); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketListenerConnectionShutdown") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketListenerSendError { pub error: Box, } @@ -107,13 +100,10 @@ impl InternalEvent for WebSocketListenerSendError { ) .increment(1); } - - fn name(&self) -> Option<&'static str> { - Some("WsListenerConnectionError") - } } #[derive(Debug)] +#[internal_event] pub struct WebSocketListenerMessageSent { pub message_size: usize, pub extra_tags: Vec<(String, String)>, @@ -125,8 +115,4 @@ impl InternalEvent for WebSocketListenerMessageSent { counter!("websocket_bytes_sent_total", &self.extra_tags) .increment(self.message_size as u64); } - - fn name(&self) -> Option<&'static str> { - Some("WebSocketListenerMessageSent") - } } diff --git a/src/sinks/elasticsearch/mod.rs b/src/sinks/elasticsearch/mod.rs index 6748c9fcc0f2e..2544c9fc8fc4d 100644 --- a/src/sinks/elasticsearch/mod.rs +++ b/src/sinks/elasticsearch/mod.rs @@ -21,8 +21,10 @@ pub use config::*; pub use encoder::ElasticsearchEncoder; use http::{Request, uri::InvalidUri}; use snafu::Snafu; +use vector_config::internal_event; use vector_lib::{ - configurable::configurable_component, internal_event, sensitive_string::SensitiveString, + configurable::configurable_component, internal_event::InternalEvent, + sensitive_string::SensitiveString, }; use crate::{ @@ -181,11 +183,12 @@ pub enum ElasticsearchCommonMode { DataStream(DataStreamConfig), } +#[internal_event] struct VersionValueParseError<'a> { value: &'a str, } -impl internal_event::InternalEvent for VersionValueParseError<'_> { +impl InternalEvent for VersionValueParseError<'_> { fn emit(self) { warn!("{self}") }