Use batch serialization format in exec output (#6446)

This commit is contained in:
Randy Coburn 2019-09-27 01:14:54 +02:00 committed by Daniel Nelson
parent aef93fd1c6
commit 62c6e30a78
1 changed files with 4 additions and 6 deletions

View File

@ -67,13 +67,11 @@ func (e *Exec) SampleConfig() string {
// Write writes the metrics to the configured command.
func (e *Exec) Write(metrics []telegraf.Metric) error {
var buffer bytes.Buffer
for _, metric := range metrics {
value, err := e.serializer.Serialize(metric)
if err != nil {
return err
}
buffer.Write(value)
serializedMetrics, err := e.serializer.SerializeBatch(metrics)
if err != nil {
return err
}
buffer.Write(serializedMetrics)
if buffer.Len() <= 0 {
return nil