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 2a840cf3de
commit ea11fae57b
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 _, metricPoint := range buildMetrics(m, w) {
metricLine := formatMetricPoint(metricPoint, w)
//log.Printf("D! Output [wavefront] %s", metricLine)
log.Printf("D! Output [wavefront] %s", metricLine)
_, err := connection.Write([]byte(metricLine))
if err != nil {
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("\n")
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"},
}
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)