From 611cd4d454407163e3cb6da5f016729ba44a079a Mon Sep 17 00:00:00 2001 From: wangguangshuo <1924240046@qq.com> Date: Thu, 18 Jan 2024 05:22:01 +0000 Subject: [PATCH] change meta to MetaServer and remove the role variable in the updateMetric function --- collector/metrics/metric_collector.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/collector/metrics/metric_collector.go b/collector/metrics/metric_collector.go index 7b3300ae60..9e6f57bbb5 100644 --- a/collector/metrics/metric_collector.go +++ b/collector/metrics/metric_collector.go @@ -121,7 +121,7 @@ func getReplicaAddrs() ([]string, error) { func (collector *Collector) initMetrics() { var addrs []string var err error - if collector.role == "meta" { + if collector.role == MetaServer { addrs = viper.GetStringSlice("meta_servers") } else { addrs, err = getReplicaAddrs() @@ -185,7 +185,7 @@ func (collector *Collector) initMetrics() { func (collector *Collector) processAllServerMetrics() { var addrs []string var err error - if collector.role == "meta" { + if collector.role == MetaServer { addrs = viper.GetStringSlice("meta_servers") } else { addrs, err = getReplicaAddrs() @@ -283,13 +283,12 @@ func (collector *Collector) updateClusterLevelTableMetrics(metricsByTableID map[ } func (collector *Collector) updateMetric(metric Metric, endpoint string, level string, title string) { - role := collector.role switch metric.mtype { case "Counter": if counter, ok := CounterMetricsMap[metric.name]; ok { counter.With( prometheus.Labels{"endpoint": endpoint, - "role": role, "level": level, + "role": collector.role, "level": level, "title": title}).Add(float64(metric.value)) } else { log.Warnf("Unknown metric name %s", metric.name) @@ -298,7 +297,7 @@ func (collector *Collector) updateMetric(metric Metric, endpoint string, level s if gauge, ok := GaugeMetricsMap[metric.name]; ok { gauge.With( prometheus.Labels{"endpoint": endpoint, - "role": role, "level": level, + "role": collector.role, "level": level, "title": title}).Set(float64(metric.value)) } else { log.Warnf("Unknown metric name %s", metric.name)