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
11#[cfg(any(
12    feature = "sources-aws_kinesis_firehose",
13    feature = "sources-exec",
14    feature = "sources-heroku_logs",
15))]
16pub(crate) fn io_error_code(error: &std::io::Error) -> &'static str {
17    use std::io::ErrorKind::*;
18
19    // there are many more gated behind https://github.com/rust-lang/rust/issues/86442
20    match error.kind() {
21        AddrInUse => "address_in_use",
22        AddrNotAvailable => "address_not_available",
23        AlreadyExists => "entity_already_exists",
24        BrokenPipe => "broken_pipe",
25        ConnectionAborted => "connection_aborted",
26        ConnectionRefused => "connection_refused",
27        ConnectionReset => "connection_reset",
28        Interrupted => "operation_interrupted",
29        InvalidData => "invalid_data",
30        InvalidInput => "invalid_input_parameter",
31        NotConnected => "not_connected",
32        NotFound => "entity_not_found",
33        Other => "other_error",
34        OutOfMemory => "out_of_memory",
35        PermissionDenied => "permission_denied",
36        TimedOut => "timed_out",
37        UnexpectedEof => "unexpected_end_of_file",
38        Unsupported => "unsupported",
39        WouldBlock => "operation_would_block",
40        WriteZero => "write_zero",
41        _ => "unknown",
42    }
43}