forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows.rs
More file actions
114 lines (102 loc) · 2.87 KB
/
windows.rs
File metadata and controls
114 lines (102 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use metrics::counter;
use vector_lib::NamedInternalEvent;
use vector_lib::internal_event::{InternalEvent, error_stage, error_type};
#[derive(Debug, NamedInternalEvent)]
pub struct WindowsServiceStart<'a> {
pub already_started: bool,
pub name: &'a str,
}
impl InternalEvent for WindowsServiceStart<'_> {
fn emit(self) {
info!(
already_started = %self.already_started,
name = self.name,
"Started Windows Service.",
);
counter!(
"windows_service_start_total",
"already_started" => self.already_started.to_string(),
)
.increment(1);
}
}
#[derive(Debug, NamedInternalEvent)]
pub struct WindowsServiceStop<'a> {
pub already_stopped: bool,
pub name: &'a str,
}
impl InternalEvent for WindowsServiceStop<'_> {
fn emit(self) {
info!(
already_stopped = %self.already_stopped,
name = ?self.name,
"Stopped Windows Service.",
);
counter!(
"windows_service_stop_total",
"already_stopped" => self.already_stopped.to_string(),
)
.increment(1);
}
}
#[derive(Debug, NamedInternalEvent)]
pub struct WindowsServiceRestart<'a> {
pub name: &'a str,
}
impl InternalEvent for WindowsServiceRestart<'_> {
fn emit(self) {
info!(
name = ?self.name,
"Restarted Windows Service."
);
counter!("windows_service_restart_total").increment(1)
}
}
#[derive(Debug, NamedInternalEvent)]
pub struct WindowsServiceInstall<'a> {
pub name: &'a str,
}
impl InternalEvent for WindowsServiceInstall<'_> {
fn emit(self) {
info!(
name = ?self.name,
"Installed Windows Service.",
);
counter!("windows_service_install_total").increment(1);
}
}
#[derive(Debug, NamedInternalEvent)]
pub struct WindowsServiceUninstall<'a> {
pub name: &'a str,
}
impl InternalEvent for WindowsServiceUninstall<'_> {
fn emit(self) {
info!(
name = ?self.name,
"Uninstalled Windows Service.",
);
counter!("windows_service_uninstall_total").increment(1);
}
}
#[derive(Debug, NamedInternalEvent)]
pub struct WindowsServiceDoesNotExistError<'a> {
pub name: &'a str,
}
impl InternalEvent for WindowsServiceDoesNotExistError<'_> {
fn emit(self) {
error!(
message = "Windows service does not exist. Maybe it needs to be installed.",
name = self.name,
error_code = "service_missing",
error_type = error_type::CONDITION_FAILED,
stage = error_stage::PROCESSING,
);
counter!(
"component_errors_total",
"error_code" => "service_missing",
"error_type" => error_type::CONDITION_FAILED,
"stage" => error_stage::PROCESSING,
)
.increment(1);
}
}