From 3589c7de69028d888e2d1fa72ca1af9120e3d35d Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Sun, 3 Jan 2021 17:57:11 +0800 Subject: [PATCH] compatible for blank tag value --- src/common/dataobj/metric.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/dataobj/metric.go b/src/common/dataobj/metric.go index 05ae460b..6b9bfaf4 100644 --- a/src/common/dataobj/metric.go +++ b/src/common/dataobj/metric.go @@ -69,7 +69,7 @@ func (m *MetricValue) CheckValidity(now int64) (err error) { } 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 } @@ -132,12 +132,16 @@ func (m *MetricValue) CheckValidity(now int64) (err error) { delete(m.TagsMap, k) k = filterString(k) v = filterString(v) - if len(k) == 0 || len(v) == 0 { - err = fmt.Errorf("tag key and value should not be empty key:%s value:%s", k, v) + if len(k) == 0 { + err = fmt.Errorf("tag key is blank, metric: %s", m.Metric) return } - m.TagsMap[k] = v + if len(v) == 0 { + m.TagsMap[k] = "nil" + } else { + m.TagsMap[k] = v + } } m.Tags = SortedTags(m.TagsMap) -- GitLab