Skip to content

Commit

Permalink
Fix metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Mar 6, 2021
1 parent 75fcbd7 commit 371bf58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions observer/monitor.go
Expand Up @@ -12,6 +12,7 @@ import (
// describing a given oberver monitor
type monitor struct {
name string
valid bool
period time.Duration
probe string
prober p.Prober
Expand Down Expand Up @@ -50,6 +51,7 @@ func (m monitor) start() *time.Ticker {

func (m monitor) New(c MonConf, log blog.Logger, prom prometheus.Registerer) *monitor {
m.name = c.getName()
m.valid = c.Valid
m.period = c.Period.Duration
m.probe = c.Probe
m.prober = c.getProber()
Expand Down
17 changes: 10 additions & 7 deletions observer/observer.go
@@ -1,6 +1,8 @@
package observer

import (
"strconv"

blog "github.com/letsencrypt/boulder/log"
// _ are probes imported to trigger init func
_ "github.com/letsencrypt/boulder/observer/probes/dns"
Expand Down Expand Up @@ -42,9 +44,12 @@ func (o Observer) Start() {

// start each monitor
for _, mon := range o.Monitors {
statTotalMonitors.WithLabelValues(mon.probe, mon.name).Inc()
// TODO(@beautifulentropy): track and restart unhealthy goroutines
go mon.start()
if mon.valid {
// TODO(@beautifulentropy): track and restart unhealthy goroutines
go mon.start()
}
statTotalMonitors.WithLabelValues(
mon.name, mon.probe, strconv.FormatBool(mon.valid)).Inc()
}
// run forever
select {}
Expand All @@ -54,10 +59,8 @@ func (o Observer) Start() {
func New(c ObsConf, l blog.Logger, p prometheus.Registerer) *Observer {
var monitors []*monitor
for _, monConf := range c.MonConfs {
if monConf.Valid {
var mon monitor
monitors = append(monitors, mon.New(*monConf, l, p))
}
var mon monitor
monitors = append(monitors, mon.New(*monConf, l, p))
}
return &Observer{l, p, monitors}
}

0 comments on commit 371bf58

Please sign in to comment.