github.com/letsencrypt/boulder@v0.20251208.0/observer/monitor.go (about) 1 package observer 2 3 import ( 4 "strconv" 5 "time" 6 7 blog "github.com/letsencrypt/boulder/log" 8 "github.com/letsencrypt/boulder/observer/probers" 9 ) 10 11 type monitor struct { 12 period time.Duration 13 prober probers.Prober 14 } 15 16 // start spins off a 'Prober' goroutine on an interval of `m.period` 17 // with a timeout of half `m.period` 18 func (m monitor) start(logger blog.Logger) { 19 ticker := time.NewTicker(m.period) 20 timeout := m.period / 2 21 for { 22 go func() { 23 // Attempt to probe the configured target. 24 success, dur := m.prober.Probe(timeout) 25 26 // Produce metrics to be scraped by Prometheus. 27 histObservations.WithLabelValues( 28 m.prober.Name(), m.prober.Kind(), strconv.FormatBool(success), 29 ).Observe(dur.Seconds()) 30 31 // Log the outcome of the probe attempt. 32 logger.Infof( 33 "kind=[%s] success=[%v] duration=[%f] name=[%s]", 34 m.prober.Kind(), success, dur.Seconds(), m.prober.Name()) 35 }() 36 <-ticker.C 37 } 38 }