Skip to main content

codecs/
lib.rs

1//! A collection of codecs that can be used to transform between bytes streams /
2//! byte messages, byte frames and structured events.
3
4#![deny(missing_docs)]
5#![deny(warnings)]
6#![deny(clippy::unwrap_used)]
7
8mod common;
9mod decoder_framed_read;
10pub mod decoding;
11pub mod encoding;
12pub mod gelf;
13pub mod internal_events;
14mod ready_frames;
15
16pub use decoder_framed_read::DecoderFramedRead;
17pub use decoding::{
18    BytesDecoder, BytesDecoderConfig, BytesDeserializer, BytesDeserializerConfig,
19    CharacterDelimitedDecoder, CharacterDelimitedDecoderConfig, Decoder, DecodingConfig,
20    DecompressionAlgorithm, DecompressionConfig, Decompressor, GelfDeserializer,
21    GelfDeserializerConfig, JsonDeserializer, JsonDeserializerConfig, LengthDelimitedDecoder,
22    LengthDelimitedDecoderConfig, NativeDeserializer, NativeDeserializerConfig,
23    NativeJsonDeserializer, NativeJsonDeserializerConfig, NewlineDelimitedDecoder,
24    NewlineDelimitedDecoderConfig, OctetCountingDecoder, OctetCountingDecoderConfig,
25    OversizedAction, StreamDecodingError, VarintLengthDelimitedDecoder,
26    VarintLengthDelimitedDecoderConfig,
27};
28#[cfg(feature = "syslog")]
29pub use decoding::{SyslogDeserializer, SyslogDeserializerConfig};
30#[cfg(feature = "arrow")]
31pub use encoding::{BatchEncoder, BatchSerializer};
32pub use encoding::{
33    BytesEncoder, BytesEncoderConfig, CharacterDelimitedEncoder, CharacterDelimitedEncoderConfig,
34    CsvSerializer, CsvSerializerConfig, Encoder, EncoderKind, EncodingConfig,
35    EncodingConfigWithFraming, GelfSerializer, GelfSerializerConfig, JsonSerializer,
36    JsonSerializerConfig, LengthDelimitedEncoder, LengthDelimitedEncoderConfig, LogfmtSerializer,
37    LogfmtSerializerConfig, NativeJsonSerializer, NativeJsonSerializerConfig, NativeSerializer,
38    NativeSerializerConfig, NewlineDelimitedEncoder, NewlineDelimitedEncoderConfig,
39    RawMessageSerializer, RawMessageSerializerConfig, SinkType, TextSerializer,
40    TextSerializerConfig, TimestampFormat, Transformer,
41};
42pub use gelf::{VALID_FIELD_REGEX, gelf_fields};
43pub use ready_frames::ReadyFrames;
44use vector_config_macros::configurable_component;
45
46/// The user configuration to choose the metric tag strategy.
47#[configurable_component]
48#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
49#[serde(rename_all = "snake_case")]
50pub enum MetricTagValues {
51    /// Tag values are exposed as single strings, the same as they were before this config
52    /// option. Tags with multiple values show the last assigned value, and null values
53    /// are ignored.
54    #[default]
55    Single,
56    /// All tags are exposed as arrays of either string or null values.
57    Full,
58    /// Tag values are exposed using their underlying shape: single-value tags as strings,
59    /// multi-value tags as arrays. A length-1 array round-trips as a scalar; use `Full` to
60    /// force array shape.
61    Auto,
62}
63
64impl From<MetricTagValues> for vector_core::event::MetricTagMode {
65    fn from(value: MetricTagValues) -> Self {
66        match value {
67            MetricTagValues::Single => Self::Single,
68            MetricTagValues::Full => Self::Full,
69            MetricTagValues::Auto => Self::Auto,
70        }
71    }
72}