vector_common/internal_event/
service.rs

1use metrics::counter;
2
3use super::{emit, error_stage, error_type, ComponentEventsDropped, InternalEvent, UNINTENTIONAL};
4
5#[derive(Debug)]
6pub struct PollReadyError<E> {
7    pub error: E,
8}
9
10impl<E: std::fmt::Debug> InternalEvent for PollReadyError<E> {
11    fn emit(self) {
12        error!(
13            message = "Service poll ready failed.",
14            error = ?self.error,
15            error_type = error_type::REQUEST_FAILED,
16            stage = error_stage::SENDING,
17            internal_log_rate_limit = true,
18        );
19        counter!(
20            "component_errors_total",
21            "error_type" => error_type::REQUEST_FAILED,
22            "stage" => error_stage::SENDING,
23        )
24        .increment(1);
25    }
26
27    fn name(&self) -> Option<&'static str> {
28        Some("ServicePollReadyError")
29    }
30}
31
32#[derive(Debug)]
33pub struct CallError<E> {
34    pub error: E,
35    pub request_id: usize,
36    pub count: usize,
37}
38
39impl<E: std::fmt::Debug> InternalEvent for CallError<E> {
40    fn emit(self) {
41        let reason = "Service call failed. No retries or retries exhausted.";
42        error!(
43            message = reason,
44            error = ?self.error,
45            request_id = self.request_id,
46            error_type = error_type::REQUEST_FAILED,
47            stage = error_stage::SENDING,
48            internal_log_rate_limit = true,
49        );
50        counter!(
51            "component_errors_total",
52            "error_type" => error_type::REQUEST_FAILED,
53            "stage" => error_stage::SENDING,
54        )
55        .increment(1);
56
57        emit(ComponentEventsDropped::<UNINTENTIONAL> {
58            reason,
59            count: self.count,
60        });
61    }
62
63    fn name(&self) -> Option<&'static str> {
64        Some("ServiceCallError")
65    }
66}