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\nOutput format (no tags):
measurement field_key=value 1700000000000000000\nTimestamp 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
impl InfluxLineProtocol
Sourcepub fn new(field_key: Option<String>, precision: Option<u8>) -> Self
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
impl Encoder for InfluxLineProtocol
Source§fn encode_metric(
&self,
event: &MetricEvent,
buf: &mut Vec<u8>,
) -> Result<(), SondaError>
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.