Skip to main content

InfluxLineProtocol

Struct InfluxLineProtocol 

Source
pub struct InfluxLineProtocol { /* private fields */ }
Expand description

Encodes MetricEvents into InfluxDB line protocol format.

The field key used for the metric value is configured at construction time. It defaults to "value".

Output format (with tags):

measurement,tag1=val1,tag2=val2 field_key=value 1700000000000000000\n

Output format (no tags):

measurement field_key=value 1700000000000000000\n

Timestamp is nanoseconds since the Unix epoch.

Characters ,, , and = are escaped with a backslash in measurement names and tag keys/values.

When precision is set, metric values are formatted to the specified number of decimal places.

Implementations§

Source§

impl InfluxLineProtocol

Source

pub fn new(field_key: Option<String>, precision: Option<u8>) -> Self

Create a new InfluxLineProtocol encoder.

field_key sets the InfluxDB field key for the metric value. If None, defaults to "value". The field key is escaped and stored at construction time to avoid per-event work.

precision optionally limits the number of decimal places in metric values. None preserves full f64 precision (default behavior).

Trait Implementations§

Source§

impl Encoder for InfluxLineProtocol

Source§

fn encode_metric( &self, event: &MetricEvent, buf: &mut Vec<u8>, ) -> Result<(), SondaError>

Encode a metric event into InfluxDB line protocol format.

Appends a complete line to buf. The buffer is not cleared before writing. Writes into the caller-provided buffer to minimize allocations.

Source§

fn encode_log( &self, _event: &LogEvent, _buf: &mut Vec<u8>, ) -> Result<(), SondaError>

Encode a log event into the provided buffer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.