-
Notifications
You must be signed in to change notification settings - Fork 18
/
main.go
72 lines (58 loc) · 1.54 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"flag"
"fmt"
"os"
"github.com/aerospike/aerospike-prometheus-exporter/internal/pkg/config"
"github.com/aerospike/aerospike-prometheus-exporter/internal/pkg/executors"
log "github.com/sirupsen/logrus"
)
var (
configFile = flag.String("config", "/etc/aerospike-prometheus-exporter/ape.toml", "Config File")
showUsage = flag.Bool("u", false, "Show usage information")
showVersion = flag.Bool("version", false, "Print version")
version = "v1.9.0"
// Gauge related
//
gaugeStatsFile = flag.String("gauge-list", "/etc/aerospike-prometheus-exporter/gauge_stats_list.toml", "Gauge stats File")
// gaugeStatHandler *GaugeStats
)
func main() {
log.Infof("Welcome to Aerospike Prometheus Exporter %s", version)
parseCommandlineArgs()
// initialize configs and gauge-stats
config.InitConfig(*configFile)
config.InitGaugeStats(*gaugeStatsFile)
if config.Cfg.Agent.PrometheusEnabled {
startExecutor("prometheus")
}
if config.Cfg.Agent.OtelEnabled {
startExecutor("otel")
}
select {}
}
func startExecutor(mode string) {
metric_handlers := executors.GetExecutors()
processor := metric_handlers[mode]
log.Infof("Starting metrics serving mode with '%s'", mode)
if processor != nil {
// start processor in a separate thread
go func() {
err := processor.Initialize()
if err != nil {
fmt.Println("Error while Initializing Processor ", err)
}
}()
}
}
func parseCommandlineArgs() {
flag.Parse()
if *showUsage {
flag.Usage()
os.Exit(0)
}
if *showVersion {
fmt.Println(version)
os.Exit(0)
}
}