Added newline to each metric line in wavefront output (#3290)

This commit is contained in:
Pierre Tessier 2017-10-02 20:42:21 -04:00 committed by Daniel Nelson
parent 0a55ab42b4
commit 79f66dc5b3
2 changed files with 4 additions and 2 deletions

View File

@ -124,7 +124,7 @@ func (w *Wavefront) Write(metrics []telegraf.Metric) error {
for _, m := range metrics { for _, m := range metrics {
for _, metricPoint := range buildMetrics(m, w) { for _, metricPoint := range buildMetrics(m, w) {
metricLine := formatMetricPoint(metricPoint, w) metricLine := formatMetricPoint(metricPoint, w)
//log.Printf("D! Output [wavefront] %s", metricLine) log.Printf("D! Output [wavefront] %s", metricLine)
_, err := connection.Write([]byte(metricLine)) _, err := connection.Write([]byte(metricLine))
if err != nil { if err != nil {
return fmt.Errorf("Wavefront: TCP writing error %s", err.Error()) return fmt.Errorf("Wavefront: TCP writing error %s", err.Error())
@ -262,6 +262,8 @@ func formatMetricPoint(metricPoint *MetricPoint, w *Wavefront) string {
buffer.WriteString("\"") buffer.WriteString("\"")
} }
buffer.WriteString("\n")
return buffer.String() return buffer.String()
} }

View File

@ -275,7 +275,7 @@ func TestFormatMetricPoint(t *testing.T) {
Tags: map[string]string{"sp*c!@l\"-ch/rs": "sp*c!@l/ val\"ue"}, Tags: map[string]string{"sp*c!@l\"-ch/rs": "sp*c!@l/ val\"ue"},
} }
expected := "test.metric.something 123.456000 1257894000 source=\"testSource\" sp-c--l--ch-rs=\"sp-c!@l/ val\\\"ue\"" expected := "test.metric.something 123.456000 1257894000 source=\"testSource\" sp-c--l--ch-rs=\"sp-c!@l/ val\\\"ue\"\n"
received := formatMetricPoint(testpoint, w) received := formatMetricPoint(testpoint, w)