github.com/influxdata/telegraf@v1.30.3/serializer.go (about)

     1  package telegraf
     2  
     3  // SerializerPlugin is an interface for plugins that are able to
     4  // serialize telegraf metrics into arbitrary data formats.
     5  type SerializerPlugin interface {
     6  	// SetSerializer sets the serializer function for the interface.
     7  	SetSerializer(serializer Serializer)
     8  }
     9  
    10  // Serializer is an interface defining functions that a serializer plugin must
    11  // satisfy.
    12  //
    13  // Implementations of this interface should be reentrant but are not required
    14  // to be thread-safe.
    15  type Serializer interface {
    16  	// Serialize takes a single telegraf metric and turns it into a byte buffer.
    17  	// separate metrics should be separated by a newline, and there should be
    18  	// a newline at the end of the buffer.
    19  	//
    20  	// New plugins should use SerializeBatch instead to allow for non-line
    21  	// delimited metrics.
    22  	Serialize(metric Metric) ([]byte, error)
    23  
    24  	// SerializeBatch takes an array of telegraf metric and serializes it into
    25  	// a byte buffer.  This method is not required to be suitable for use with
    26  	// line oriented framing.
    27  	SerializeBatch(metrics []Metric) ([]byte, error)
    28  }