vector/internal_events/
process.rs1use vector_lib::{
2 NamedInternalEvent, counter,
3 internal_event::{CounterName, InternalEvent, error_stage, error_type},
4};
5
6use crate::{built_info, config};
7
8#[derive(Debug, NamedInternalEvent)]
9pub struct VectorStarted;
10
11impl InternalEvent for VectorStarted {
12 fn emit(self) {
13 info!(
14 target: "vector",
15 message = "Vector has started.",
16 debug = built_info::DEBUG,
17 version = built_info::PKG_VERSION,
18 arch = built_info::TARGET_ARCH,
19 revision = built_info::VECTOR_BUILD_DESC.unwrap_or(""),
20 );
21 counter!(CounterName::StartedTotal).increment(1);
22 }
23}
24
25#[derive(Debug, NamedInternalEvent)]
26pub struct VectorReloaded<'a> {
27 pub config_paths: &'a [config::ConfigPath],
28}
29
30impl InternalEvent for VectorReloaded<'_> {
31 fn emit(self) {
32 info!(
33 target: "vector",
34 message = "Vector has reloaded.",
35 path = ?self.config_paths,
36 internal_log_rate_limit = false,
37 );
38 counter!(CounterName::ReloadedTotal).increment(1);
39 }
40}
41
42#[derive(Debug, NamedInternalEvent)]
43pub struct VectorStopping;
44
45impl InternalEvent for VectorStopping {
46 fn emit(self) {
47 info!(
48 target: "vector",
49 message = "Vector is stopping.",
50 );
51 }
52}
53
54#[derive(Debug, NamedInternalEvent)]
55pub struct VectorStopped;
56
57impl InternalEvent for VectorStopped {
58 fn emit(self) {
59 info!(
60 target: "vector",
61 message = "Vector has stopped.",
62 );
63 counter!(CounterName::StoppedTotal).increment(1);
64 }
65}
66
67#[derive(Debug, NamedInternalEvent)]
68pub struct VectorQuit;
69
70impl InternalEvent for VectorQuit {
71 fn emit(self) {
72 info!(
73 target: "vector",
74 message = "Vector has quit.",
75 );
76 counter!(CounterName::QuitTotal).increment(1);
77 }
78}
79
80#[derive(Debug, NamedInternalEvent)]
81pub struct VectorReloadError {
82 pub reason: &'static str,
83}
84
85impl InternalEvent for VectorReloadError {
86 fn emit(self) {
87 error!(
88 message = "Reload was not successful.",
89 reason = self.reason,
90 error_code = "reload",
91 error_type = error_type::CONFIGURATION_FAILED,
92 stage = error_stage::PROCESSING,
93 internal_log_rate_limit = false,
94 );
95 counter!(
96 CounterName::ComponentErrorsTotal,
97 "error_code" => "reload",
98 "error_type" => error_type::CONFIGURATION_FAILED,
99 "stage" => error_stage::PROCESSING,
100 "reason" => self.reason,
101 )
102 .increment(1);
103 }
104}
105
106#[derive(Debug, NamedInternalEvent)]
107pub struct VectorConfigLoadError;
108
109impl InternalEvent for VectorConfigLoadError {
110 fn emit(self) {
111 error!(
112 message = "Failed to load config files, reload aborted.",
113 error_code = "config_load",
114 error_type = error_type::CONFIGURATION_FAILED,
115 stage = error_stage::PROCESSING,
116 internal_log_rate_limit = false,
117 );
118 counter!(
119 CounterName::ComponentErrorsTotal,
120 "error_code" => "config_load",
121 "error_type" => error_type::CONFIGURATION_FAILED,
122 "stage" => error_stage::PROCESSING,
123 )
124 .increment(1);
125 }
126}
127
128#[derive(Debug, NamedInternalEvent)]
129pub struct VectorRecoveryError;
130
131impl InternalEvent for VectorRecoveryError {
132 fn emit(self) {
133 error!(
134 message = "Vector has failed to recover from a failed reload.",
135 error_code = "recovery",
136 error_type = error_type::CONFIGURATION_FAILED,
137 stage = error_stage::PROCESSING,
138 internal_log_rate_limit = false,
139 );
140 counter!(
141 CounterName::ComponentErrorsTotal,
142 "error_code" => "recovery",
143 "error_type" => error_type::CONFIGURATION_FAILED,
144 "stage" => error_stage::PROCESSING,
145 )
146 .increment(1);
147 }
148}