From 81f474b80a92546d94cb950075914d8c487f4c23 Mon Sep 17 00:00:00 2001 From: zhuofeng Date: Tue, 26 Nov 2024 18:48:54 +0800 Subject: [PATCH] feat: stats counter supports storing string type as tag --- server/libs/stats/stats.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/libs/stats/stats.go b/server/libs/stats/stats.go index 06ba53a6ae88..4545c8e70a5a 100644 --- a/server/libs/stats/stats.go +++ b/server/libs/stats/stats.go @@ -254,8 +254,14 @@ func sendStatsd(bp client.BatchPoints) { dfStats.TagValues = append(dfStats.TagValues, point.Tags()[v]) } - for k := range fields { - dfStats.MetricsFloatNames = append(dfStats.MetricsFloatNames, k) + for k, v := range fields { + switch v.(type) { + case string: + dfStats.TagNames = append(dfStats.TagNames, k) + dfStats.TagValues = append(dfStats.TagValues, v.(string)) + default: + dfStats.MetricsFloatNames = append(dfStats.MetricsFloatNames, k) + } } sort.Slice(dfStats.MetricsFloatNames, func(i, j int) bool { return dfStats.MetricsFloatNames[i] < dfStats.MetricsFloatNames[j]