pub trait Encoder: Send + Sync {
// Required method
fn encode_metric(
&self,
event: &MetricEvent,
buf: &mut Vec<u8>,
) -> Result<(), SondaError>;
// Provided method
fn encode_log(
&self,
_event: &LogEvent,
_buf: &mut Vec<u8>,
) -> Result<(), SondaError> { ... }
}Expand description
Encodes telemetry events into a specific wire format.
Implementations should pre-build any invariant content (label prefixes, metric name validation) at construction time.
Required Methods§
Sourcefn 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 the provided buffer.
Provided Methods§
Sourcefn encode_log(
&self,
_event: &LogEvent,
_buf: &mut Vec<u8>,
) -> Result<(), SondaError>
fn encode_log( &self, _event: &LogEvent, _buf: &mut Vec<u8>, ) -> Result<(), SondaError>
Encode a log event into the provided buffer.
Returns an error by default. Encoders that support log encoding must override this method.