From c3b8149e11f414b44451c8ff21c3b8da4d820140 Mon Sep 17 00:00:00 2001 From: Eric Fortin Date: Fri, 19 Aug 2016 09:44:31 -0400 Subject: [PATCH] Removed TagSet type to make it more explicit. --- plugins/outputs/opentsdb/opentsdb.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/plugins/outputs/opentsdb/opentsdb.go b/plugins/outputs/opentsdb/opentsdb.go index 033bb69c2..d7b3eb915 100644 --- a/plugins/outputs/opentsdb/opentsdb.go +++ b/plugins/outputs/opentsdb/opentsdb.go @@ -46,17 +46,15 @@ var sampleConfig = ` debug = false ` -type TagSet map[string]string - -func (t TagSet) ToLineFormat() string { - tags := make([]string, len(t)) +func ToLineFormat(tags map[string]string) string { + tagsArray := make([]string, len(tags)) index := 0 - for k, v := range t { - tags[index] = fmt.Sprintf("%s=%s", k, v) + for k, v := range tags { + tagsArray[index] = fmt.Sprintf("%s=%s", k, v) index++ } - sort.Strings(tags) - return strings.Join(tags, " ") + sort.Strings(tagsArray) + return strings.Join(tagsArray, " ") } func (o *OpenTSDB) Connect() error { @@ -150,7 +148,7 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error { for _, m := range metrics { now := m.UnixNano() / 1000000000 - tags := cleanTags(m.Tags()).ToLineFormat() + tags := ToLineFormat(cleanTags(m.Tags())) for fieldName, value := range m.Fields() { metricValue, buildError := buildValue(value) @@ -176,7 +174,7 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error { return nil } -func cleanTags(tags map[string]string) TagSet { +func cleanTags(tags map[string]string) map[string]string { tagSet := make(map[string]string, len(tags)) for k, v := range tags { tagSet[sanitizedChars.Replace(k)] = sanitizedChars.Replace(v)