remove empty tag when sinking data to influxdb
size tag map allocation in influxdb sync
@@ -82,12 +82,17 @@ func (sink *influxdbSink) ExportData(dataBatch *core.DataBatch) {
point := influxdb.Point{
Measurement: measurementName,
- Tags: metricSet.Labels,
+ Tags: make(map[string]string, len(metricSet.Labels)),
Fields: map[string]interface{}{
fieldName: value,
},
Time: dataBatch.Timestamp.UTC(),
}
+ for key, value := range metricSet.Labels {
+ if value != "" {
+ point.Tags[key] = value
+ }
+ }
dataPoints = append(dataPoints, point)
if len(dataPoints) >= maxSendBatchSize {
sink.sendData(dataPoints)
@@ -120,18 +125,22 @@ func (sink *influxdbSink) ExportData(dataBatch *core.DataBatch) {
point := influxdb.Point{
Measurement: measurementName,
- Tags: make(map[string]string),
+ Tags: make(map[string]string, len(metricSet.Labels)+len(labeledMetric.Labels)),
Fields: map[string]interface{}{
fieldName: value,
},
Time: dataBatch.Timestamp.UTC(),
}
for key, value := range metricSet.Labels {
+ if value != "" {
point.Tags[key] = value
}
+ }
for key, value := range labeledMetric.Labels {
+ if value != "" {
point.Tags[key] = value
}
+ }
dataPoints = append(dataPoints, point)
if len(dataPoints) >= maxSendBatchSize {
