vector/internal_events/
prelude.rs

1#[cfg(any(
2    feature = "sources-apache_metrics",
3    feature = "sources-aws_ecs_metrics",
4    feature = "sources-aws_kinesis_firehose",
5    feature = "sources-utils-http",
6))]
7pub(crate) fn http_error_code(code: u16) -> String {
8    format!("http_response_{code}")
9}
10
11pub(crate) fn io_error_code(error: &std::io::Error) -> &'static str {
12    use std::io::ErrorKind::*;
13
14    // there are many more gated behind https://github.com/rust-lang/rust/issues/86442
15    match error.kind() {
16        AddrInUse => "address_in_use",
17        AddrNotAvailable => "address_not_available",
18        AlreadyExists => "entity_already_exists",
19        BrokenPipe => "broken_pipe",
20        ConnectionAborted => "connection_aborted",
21        ConnectionRefused => "connection_refused",
22        ConnectionReset => "connection_reset",
23        Interrupted => "operation_interrupted",
24        InvalidData => "invalid_data",
25        InvalidInput => "invalid_input_parameter",
26        NotConnected => "not_connected",
27        NotFound => "entity_not_found",
28        Other => "other_error",
29        OutOfMemory => "out_of_memory",
30        PermissionDenied => "permission_denied",
31        TimedOut => "timed_out",
32        UnexpectedEof => "unexpected_end_of_file",
33        Unsupported => "unsupported",
34        WouldBlock => "operation_would_block",
35        WriteZero => "write_zero",
36        _ => "unknown",
37    }
38}