Skip to content

Commit bd6885e

Browse files
committed
Finish refactor
1 parent c33012d commit bd6885e

File tree

2 files changed

+408
-384
lines changed

2 files changed

+408
-384
lines changed

main.go

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"sync"
99
"time"
1010

11-
cfaccounts "github.com/cloudflare/cloudflare-go/v4/accounts"
1211
"github.com/nelkinda/health-go"
1312
"github.com/prometheus/client_golang/prometheus/promhttp"
1413
"github.com/spf13/cobra"
@@ -27,19 +26,6 @@ var (
2726
log = logrus.New()
2827
)
2928

30-
// var (
31-
// cfgListen = ":8080"
32-
// cfgCfAPIKey = ""
33-
// cfgCfAPIEmail = ""
34-
// cfgCfAPIToken = ""
35-
// cfgMetricsPath = "/metrics"
36-
// cfgZones = ""
37-
// cfgExcludeZones = ""
38-
// cfgScrapeDelay = 300
39-
// cfgFreeTier = false
40-
// cfgMetricsDenylist = ""
41-
// )
42-
4329
func getTargetZones() []string {
4430
var zoneIDs []string
4531

@@ -104,14 +90,10 @@ func filterExcludedZones(all []cfzones.Zone, exclude []string) []cfzones.Zone {
10490
return filtered
10591
}
10692

107-
func fetchMetrics(deniedMetricsSet MetricsSet) {
93+
func fetchMetrics(deniedMetricsSet []string) {
10894
var wg sync.WaitGroup
10995
accounts := fetchAccounts()
11096

111-
accounts = []cfaccounts.Account{cfaccounts.Account{
112-
ID: "22d2b105f2800afd70234ceef6634238",
113-
}}
114-
11597
for _, a := range accounts {
11698
go fetchWorkerAnalytics(a, &wg)
11799
go fetchLogpushAnalyticsForAccount(a, &wg)
@@ -168,19 +150,15 @@ func runExporter() {
168150
if len(viper.GetString("metrics_denylist")) > 0 {
169151
metricsDenylist = strings.Split(viper.GetString("metrics_denylist"), ",")
170152
}
171-
metricsSet, err := buildFilteredMetricsSet(metricsDenylist)
172-
if err != nil {
173-
log.Fatalf("Error building metrics set: %v", err)
174-
}
175-
log.Debugf("Metrics set: %v", metricsSet)
176-
mustRegisterMetrics(metricsSet)
153+
154+
mustRegisterMetrics(metricsDenylist)
177155

178156
scrapeInterval := time.Duration(viper.GetInt("scrape_interval")) * time.Second
179157
log.Info("Scrape interval set to ", scrapeInterval)
180158

181159
go func() {
182160
for ; true; <-time.NewTicker(scrapeInterval).C {
183-
go fetchMetrics(metricsSet)
161+
go fetchMetrics(metricsDenylist)
184162
}
185163
}()
186164

0 commit comments

Comments
 (0)