Skip to content

Commit

Permalink
change meta to MetaServer and remove the role variable in the updateM…
Browse files Browse the repository at this point in the history
…etric function
  • Loading branch information
limowang committed Jan 18, 2024
1 parent 99659c0 commit 611cd4d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions collector/metrics/metric_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 611cd4d

Please sign in to comment.