code refactor: remove unused field(TagsLst) of MetricPoint

This commit is contained in:
Ulric Qin 2021-08-22 08:45:29 +08:00
parent e288a3d3a9
commit de99077b32
2 changed files with 6 additions and 5 deletions

View File

@ -110,17 +110,19 @@ func enrich(point *vos.MetricPoint) {
}
}
var tagsLst []string
// 根据tagsmap生成tagslstsort
count := len(point.TagsMap)
if count == 0 {
point.TagsLst = []string{}
tagsLst = []string{}
} else {
lst := make([]string, 0, count)
for k, v := range point.TagsMap {
lst = append(lst, k+"="+v)
}
sort.Strings(lst)
point.TagsLst = lst
tagsLst = lst
}
// ident metric tagslst 生成 pk
@ -131,8 +133,8 @@ func enrich(point *vos.MetricPoint) {
ret.WriteString(point.Ident)
ret.WriteString(point.Metric)
for i := 0; i < len(point.TagsLst); i++ {
ret.WriteString(point.TagsLst[i])
for i := 0; i < len(tagsLst); i++ {
ret.WriteString(tagsLst[i])
}
point.PK = str.MD5(ret.String())

View File

@ -21,7 +21,6 @@ type MetricPoint struct {
Alias string `json:"alias"` // 资源名称,跟资源无关的监控数据,该字段为空
Metric string `json:"metric"` // 监控指标名称
TagsMap map[string]string `json:"tags"` // 监控数据标签
TagsLst []string `json:"-"` // 内部字段用于对TagsMap排序
Time int64 `json:"time"` // 时间戳,单位是秒
ValueUntyped interface{} `json:"value"` // 监控数据数值可以是int float string但最终要能转换为float64
Value float64 `json:"-"` // 内部字段最终转换之后的float64数值