Skip to content

Commit

Permalink
Gauge with instance's version
Browse files Browse the repository at this point in the history
  • Loading branch information
mlowicki committed Oct 22, 2018
1 parent 2ea1bbc commit 8e4239f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions rhythm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,39 @@ var leaderGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "leader",
Help: "Indicates if instance is elected as leader.",
})
var infoGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "rhythm_info",
Help: "Information about rhythm instance.",
}, []string{"version"})

func init() {
prometheus.MustRegister(leaderGauge)
prometheus.MustRegister(infoGauge)
}

const version = "0.1"

func main() {
confPath := flag.String("config", "config.json", "Path to configuration file")
testLogging := flag.Bool("testlogging", false, "log sample error and exit")
version := flag.Bool("version", false, "print version and exit")
testLoggingFlag := flag.Bool("testlogging", false, "log sample error and exit")
versionFlag := flag.Bool("version", false, "print version and exit")
flag.Parse()
if *version {
fmt.Println("0.1")
if *versionFlag {
fmt.Println(version)
return
}
var conf, err = conf.New(*confPath)
if err != nil {
log.Fatalf("Error getting configuration: %s", err)
}
initLogging(&conf.Logging)
if *testLogging {
if *testLoggingFlag {
log.Error("test")
log.Info("Sending test event. Wait 10s...")
<-time.After(10 * time.Second)
return
}
infoGauge.WithLabelValues(version).Set(1)
stor := storage.New(&conf.Storage)
coord := coordinator.New(&conf.Coordinator)
api.New(&conf.API, stor)
Expand Down

0 comments on commit 8e4239f

Please sign in to comment.