Encoder

Trait Encoder 

Source
pub trait Encoder {
    // Required method
    fn run<'async_trait>(
        self: Box<Self>,
        context: EncoderContext,
    ) -> Pin<Box<dyn Future<Output = Result<(), GenericError>> + Send + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

A encoder.

Encoders are the bridge between forwarders and the rest of the topology. They are responsible for encoding telemetry events into output payloads that can then be forwarded. Most encoders are specific to a particular system and not simply equivalent to a certain encoding or serialization format: while two encoders may both produce JSON, they may produce different JSON formats such that one format only works for product A and the other only works for product B. In essence, the process of taking telemetry events and sending them to product A ends up becoming the sum of a specific encoder and forwarder combination.

Examples of typical encoders include Datadog Metrics, Events, and Service Checks.

Required Methods§

Source

fn run<'async_trait>( self: Box<Self>, context: EncoderContext, ) -> Pin<Box<dyn Future<Output = Result<(), GenericError>> + Send + 'async_trait>>
where Self: 'async_trait,

Runs the encoder.

The encoder context provides access primarily to the event stream, used to receive events sent to the encoder, and the forwarder, used to send payloads to the downstream forwarder in the topology, as well as other information such as the component context.

Encoders are expected to run indefinitely until their event stream is terminated, or an error occurs.

§Errors

If an unrecoverable error occurs while running, an error is returned.

Implementors§