Add SerializeBatch method to the Serializer interface (#4107)

This commit is contained in:
Daniel Nelson
2018-05-04 18:27:31 -07:00
committed by GitHub
parent de355b76d6
commit 73c22a8189
9 changed files with 302 additions and 84 deletions

View File

@@ -25,6 +25,11 @@ type Serializer interface {
// separate metrics should be separated by a newline, and there should be
// a newline at the end of the buffer.
Serialize(metric telegraf.Metric) ([]byte, error)
// SerializeBatch takes an array of telegraf metric and serializes it into
// a byte buffer. This method is not required to be suitable for use with
// line oriented framing.
SerializeBatch(metrics []telegraf.Metric) ([]byte, error)
}
// Config is a struct that covers the data types needed for all serializer types,
@@ -72,7 +77,7 @@ func NewSerializer(config *Config) (Serializer, error) {
}
func NewJsonSerializer(timestampUnits time.Duration) (Serializer, error) {
return &json.JsonSerializer{TimestampUnits: timestampUnits}, nil
return json.NewSerializer(timestampUnits)
}
func NewInfluxSerializerConfig(config *Config) (Serializer, error) {