Fix InfluxDB output UDP line splitting (#5439)
This commit is contained in:
committed by
Daniel Nelson
parent
e4d084fbc3
commit
5dfa3fa769
@@ -240,6 +240,7 @@ func (s *Serializer) writeMetric(w io.Writer, m telegraf.Metric) error {
|
||||
return err
|
||||
}
|
||||
|
||||
pairsLen = 0
|
||||
firstField = true
|
||||
bytesNeeded = len(s.header) + len(s.pair) + len(s.footer)
|
||||
|
||||
|
||||
@@ -275,6 +275,24 @@ var tests = []struct {
|
||||
),
|
||||
output: []byte("cpu abc=123i 1519194109000000042\ncpu def=456i 1519194109000000042\n"),
|
||||
},
|
||||
{
|
||||
name: "split_fields_overflow",
|
||||
maxBytes: 43,
|
||||
input: MustMetric(
|
||||
metric.New(
|
||||
"cpu",
|
||||
map[string]string{},
|
||||
map[string]interface{}{
|
||||
"abc": 123,
|
||||
"def": 456,
|
||||
"ghi": 789,
|
||||
"jkl": 123,
|
||||
},
|
||||
time.Unix(1519194109, 42),
|
||||
),
|
||||
),
|
||||
output: []byte("cpu abc=123i,def=456i 1519194109000000042\ncpu ghi=789i,jkl=123i 1519194109000000042\n"),
|
||||
},
|
||||
{
|
||||
name: "name newline",
|
||||
input: MustMetric(
|
||||
|
||||
Reference in New Issue
Block a user