vector_common/internal_event/
service.rs

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