vector/internal_events/
process.rs

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