Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(collector): fix lint and build errors for go collector #1762

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/lint_and_test_collector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ on:
- ci-test # testing branch for github action
- '*dev'
paths:
- collector/**
- '.github/workflows/lint_and_test_collector.yml'
- 'collector/**'

# for manually triggering workflow
workflow_dispatch:
Expand All @@ -47,7 +48,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.14
go-version: 1.17
cache: false
- name: Lint
uses: golangci/golangci-lint-action@v3
Expand All @@ -66,7 +67,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.17
- name: Build
working-directory: ./collector
run: make
4 changes: 2 additions & 2 deletions collector/avail/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ type pegasusDetector struct {
detectTableName string
detectInterval time.Duration
// timeout of a single detect.
detectTimeout time.Duration
detectTimeout time.Duration
// partition count.
partitionCount int
partitionCount int
}

func (d *pegasusDetector) Start(tom *tomb.Tomb) error {
Expand Down
48 changes: 24 additions & 24 deletions collector/metrics/metric_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (collector *Collector) Start(tom *tomb.Tomb) error {
func getReplicaAddrs() ([]string, error) {
addrs := viper.GetStringSlice("meta_servers")
var rserverAddrs []string
for addr := range addrs {
for _, addr := range addrs {
url := fmt.Sprintf("http://%s/meta/nodes", addr)
resp, err := http.Get(url)
if err == nil && resp.StatusCode != http.StatusOK {
Expand Down Expand Up @@ -291,29 +291,29 @@ func updateClusterLevelTableMetrics(metricsByTableID map[string]Metrics) {
func updateMetric(metric Metric, endpoint string, level string, title string) {
role := RoleByDataSource[DataSource]
switch metric.mtype {
case "Counter":
if counter, ok := CounterMetricsMap[metric.name]; ok {
counter.With(
prometheus.Labels{"endpoint": endpoint,
"role": role, "level": level,
"title": title}).Add(float64(metric.value))
} else {
log.Warnf("Unknown metric name %s", metric.name)
}
case "Gauge":
if gauge, ok := GaugeMetricsMap[metric.name]; ok {
gauge.With(
prometheus.Labels{"endpoint": endpoint,
"role": role, "level": level,
"title": title}).Set(float64(metric.value))
} else {
log.Warnf("Unknown metric name %s", metric.name)
}
case "Percentile":
log.Warnf("Todo metric type %s", metric.mtype)
case "Histogram":
default:
log.Warnf("Unsupport metric type %s", metric.mtype)
case "Counter":
if counter, ok := CounterMetricsMap[metric.name]; ok {
counter.With(
prometheus.Labels{"endpoint": endpoint,
"role": role, "level": level,
"title": title}).Add(float64(metric.value))
} else {
log.Warnf("Unknown metric name %s", metric.name)
}
case "Gauge":
if gauge, ok := GaugeMetricsMap[metric.name]; ok {
gauge.With(
prometheus.Labels{"endpoint": endpoint,
"role": role, "level": level,
"title": title}).Set(float64(metric.value))
} else {
log.Warnf("Unknown metric name %s", metric.name)
}
case "Percentile":
log.Warnf("Todo metric type %s", metric.mtype)
case "Histogram":
default:
log.Warnf("Unsupport metric type %s", metric.mtype)
}
}

Expand Down
Loading