compatible for blank tag value

This commit is contained in:
Ulric Qin 2021-01-03 17:57:11 +08:00
parent 72cf2c7578
commit 3589c7de69
1 changed files with 8 additions and 4 deletions

View File

@ -69,7 +69,7 @@ func (m *MetricValue) CheckValidity(now int64) (err error) {
} }
if m.Nid == "" && m.Endpoint == "" { if m.Nid == "" && m.Endpoint == "" {
err = fmt.Errorf("nid and endpoint should not be empty") err = fmt.Errorf("nid and endpoint should not be both empty")
return return
} }
@ -132,13 +132,17 @@ func (m *MetricValue) CheckValidity(now int64) (err error) {
delete(m.TagsMap, k) delete(m.TagsMap, k)
k = filterString(k) k = filterString(k)
v = filterString(v) v = filterString(v)
if len(k) == 0 || len(v) == 0 { if len(k) == 0 {
err = fmt.Errorf("tag key and value should not be empty key:%s value:%s", k, v) err = fmt.Errorf("tag key is blank, metric: %s", m.Metric)
return return
} }
if len(v) == 0 {
m.TagsMap[k] = "nil"
} else {
m.TagsMap[k] = v m.TagsMap[k] = v
} }
}
m.Tags = SortedTags(m.TagsMap) m.Tags = SortedTags(m.TagsMap)
if len(m.Tags) > 512 { if len(m.Tags) > 512 {