Removed TagSet type to make it more explicit.
This commit is contained in:
parent
fbaa6f8490
commit
c3b8149e11
|
@ -46,17 +46,15 @@ var sampleConfig = `
|
||||||
debug = false
|
debug = false
|
||||||
`
|
`
|
||||||
|
|
||||||
type TagSet map[string]string
|
func ToLineFormat(tags map[string]string) string {
|
||||||
|
tagsArray := make([]string, len(tags))
|
||||||
func (t TagSet) ToLineFormat() string {
|
|
||||||
tags := make([]string, len(t))
|
|
||||||
index := 0
|
index := 0
|
||||||
for k, v := range t {
|
for k, v := range tags {
|
||||||
tags[index] = fmt.Sprintf("%s=%s", k, v)
|
tagsArray[index] = fmt.Sprintf("%s=%s", k, v)
|
||||||
index++
|
index++
|
||||||
}
|
}
|
||||||
sort.Strings(tags)
|
sort.Strings(tagsArray)
|
||||||
return strings.Join(tags, " ")
|
return strings.Join(tagsArray, " ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OpenTSDB) Connect() error {
|
func (o *OpenTSDB) Connect() error {
|
||||||
|
@ -150,7 +148,7 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error {
|
||||||
|
|
||||||
for _, m := range metrics {
|
for _, m := range metrics {
|
||||||
now := m.UnixNano() / 1000000000
|
now := m.UnixNano() / 1000000000
|
||||||
tags := cleanTags(m.Tags()).ToLineFormat()
|
tags := ToLineFormat(cleanTags(m.Tags()))
|
||||||
|
|
||||||
for fieldName, value := range m.Fields() {
|
for fieldName, value := range m.Fields() {
|
||||||
metricValue, buildError := buildValue(value)
|
metricValue, buildError := buildValue(value)
|
||||||
|
@ -176,7 +174,7 @@ func (o *OpenTSDB) WriteTelnet(metrics []telegraf.Metric, u *url.URL) error {
|
||||||
return nil
|
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))
|
tagSet := make(map[string]string, len(tags))
|
||||||
for k, v := range tags {
|
for k, v := range tags {
|
||||||
tagSet[sanitizedChars.Replace(k)] = sanitizedChars.Replace(v)
|
tagSet[sanitizedChars.Replace(k)] = sanitizedChars.Replace(v)
|
||||||
|
|
Loading…
Reference in New Issue