diff --git a/plugins/outputs/graphite/graphite.go b/plugins/outputs/graphite/graphite.go index 299fe69c6..2903f1fe0 100644 --- a/plugins/outputs/graphite/graphite.go +++ b/plugins/outputs/graphite/graphite.go @@ -14,10 +14,10 @@ import ( type Graphite struct { // URL is only for backwards compatability - Servers []string - Timeout int + Servers []string + Timeout int - conns []net.Conn + conns []net.Conn serializer serializers.Serializer } diff --git a/plugins/outputs/graphite/graphite_test.go b/plugins/outputs/graphite/graphite_test.go index 4fc41f2e1..8b11388ec 100644 --- a/plugins/outputs/graphite/graphite_test.go +++ b/plugins/outputs/graphite/graphite_test.go @@ -11,9 +11,9 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/metric" + "github.com/influxdata/telegraf/plugins/serializers/graphite" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/influxdata/telegraf/plugins/serializers/graphite" ) func TestGraphiteError(t *testing.T) { diff --git a/plugins/outputs/instrumental/instrumental.go b/plugins/outputs/instrumental/instrumental.go index bd9f1d323..c0a35888c 100644 --- a/plugins/outputs/instrumental/instrumental.go +++ b/plugins/outputs/instrumental/instrumental.go @@ -22,12 +22,12 @@ var ( ) type Instrumental struct { - Host string - ApiToken string - Timeout internal.Duration - Debug bool + Host string + ApiToken string + Timeout internal.Duration + Debug bool - conn net.Conn + conn net.Conn serializer serializers.Serializer } @@ -210,7 +210,7 @@ func (i *Instrumental) authenticate(conn net.Conn) error { func init() { outputs.Add("instrumental", func() telegraf.Output { return &Instrumental{ - Host: DefaultHost, + Host: DefaultHost, } }) } diff --git a/plugins/outputs/instrumental/instrumental_test.go b/plugins/outputs/instrumental/instrumental_test.go index 33689c1b1..01d390769 100644 --- a/plugins/outputs/instrumental/instrumental_test.go +++ b/plugins/outputs/instrumental/instrumental_test.go @@ -10,8 +10,8 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/metric" - "github.com/stretchr/testify/assert" "github.com/influxdata/telegraf/plugins/serializers/graphite" + "github.com/stretchr/testify/assert" ) func TestWrite(t *testing.T) { diff --git a/plugins/serializers/graphite/graphite.go b/plugins/serializers/graphite/graphite.go index be028c12c..2caf14000 100644 --- a/plugins/serializers/graphite/graphite.go +++ b/plugins/serializers/graphite/graphite.go @@ -5,8 +5,8 @@ import ( "sort" "strings" - "github.com/influxdata/telegraf" "encoding/json" + "github.com/influxdata/telegraf" ) const ( @@ -26,8 +26,8 @@ type GraphiteSerializer struct { // GraphiteJson struct for json processing. type GraphiteJson struct { - Path string `json:"path"` - Value string `json:"value"` + Path string `json:"path"` + Value string `json:"value"` Timestamp string `json:"timestamp"` } @@ -54,8 +54,8 @@ func jsonSerialize(bucket string, metric telegraf.Metric, timestamp int64) ([]by for fieldName, value := range metric.Fields() { out = append(out, GraphiteJson{ - Path: sanitizedChars.Replace(InsertField(bucket, fieldName)), - Value: sanitizedChars.Replace(fmt.Sprintf("%#v", value)), + Path: sanitizedChars.Replace(InsertField(bucket, fieldName)), + Value: sanitizedChars.Replace(fmt.Sprintf("%#v", value)), Timestamp: fmt.Sprintf("%d", timestamp), }) } diff --git a/plugins/serializers/graphite/graphite_test.go b/plugins/serializers/graphite/graphite_test.go index 48674b8c1..16c10de03 100644 --- a/plugins/serializers/graphite/graphite_test.go +++ b/plugins/serializers/graphite/graphite_test.go @@ -490,14 +490,14 @@ func TestSerializerWithJsonProtocol2(t *testing.T) { // then actualS := string(buf) - expS := fmt.Sprintf("[" + - "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}," + - "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}" + + expS := fmt.Sprintf("["+ + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"},"+ + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}"+ "]", now.Unix(), now.Unix()) - reorderedExpS := fmt.Sprintf("[" + - "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"}," + - "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}" + + reorderedExpS := fmt.Sprintf("["+ + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_busy\",\"value\":\"8.5\",\"timestamp\":\"%d\"},"+ + "{\"path\":\"localhost.cpu0.us-west-2.cpu.usage_idle\",\"value\":\"91.5\",\"timestamp\":\"%d\"}"+ "]", now.Unix(), now.Unix()) // serialize function uses internally map. result is not same everytime because map is not guaranteed key ordering. @@ -507,4 +507,4 @@ func TestSerializerWithJsonProtocol2(t *testing.T) { } else { assert.True(t, false) } -} \ No newline at end of file +} diff --git a/plugins/serializers/registry.go b/plugins/serializers/registry.go index 0684a7828..3c627145d 100644 --- a/plugins/serializers/registry.go +++ b/plugins/serializers/registry.go @@ -67,7 +67,7 @@ func NewInfluxSerializer() (Serializer, error) { } func NewGraphiteSerializer(prefix, template, protocol string) (Serializer, error) { - return &graphite.GraphiteSerializer{ + return &graphite.GraphiteSerializer{ Prefix: prefix, Template: template, Protocol: protocol,