Skip to content
This repository was archived by the owner on Dec 1, 2018. It is now read-only.

Commit e7b3372

Browse files
authored
Merge pull request #1627 from watercraft/master
remove empty tag when sinking data to influxdb
2 parents b109f11 + 723c346 commit e7b3372

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

metrics/sinks/influxdb/influxdb.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ func (sink *influxdbSink) ExportData(dataBatch *core.DataBatch) {
8282

8383
point := influxdb.Point{
8484
Measurement: measurementName,
85-
Tags: metricSet.Labels,
85+
Tags: make(map[string]string, len(metricSet.Labels)),
8686
Fields: map[string]interface{}{
8787
fieldName: value,
8888
},
8989
Time: dataBatch.Timestamp.UTC(),
9090
}
91+
for key, value := range metricSet.Labels {
92+
if value != "" {
93+
point.Tags[key] = value
94+
}
95+
}
9196
dataPoints = append(dataPoints, point)
9297
if len(dataPoints) >= maxSendBatchSize {
9398
sink.sendData(dataPoints)
@@ -120,17 +125,21 @@ func (sink *influxdbSink) ExportData(dataBatch *core.DataBatch) {
120125

121126
point := influxdb.Point{
122127
Measurement: measurementName,
123-
Tags: make(map[string]string),
128+
Tags: make(map[string]string, len(metricSet.Labels)+len(labeledMetric.Labels)),
124129
Fields: map[string]interface{}{
125130
fieldName: value,
126131
},
127132
Time: dataBatch.Timestamp.UTC(),
128133
}
129134
for key, value := range metricSet.Labels {
130-
point.Tags[key] = value
135+
if value != "" {
136+
point.Tags[key] = value
137+
}
131138
}
132139
for key, value := range labeledMetric.Labels {
133-
point.Tags[key] = value
140+
if value != "" {
141+
point.Tags[key] = value
142+
}
134143
}
135144

136145
dataPoints = append(dataPoints, point)

0 commit comments

Comments
 (0)