observer: Monitors probe immediately instead of waiting a full duration (#6594)

Do work on startup to limit the likelihood of post-deployment runtime panics.
This commit is contained in:
Preston Locke 2023-01-24 15:45:19 -06:00 committed by GitHub
parent 0d6f8569c5
commit 7d3fc60271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -18,8 +18,8 @@ type monitor struct {
func (m monitor) start(logger blog.Logger) {
ticker := time.NewTicker(m.period)
timeout := m.period / 2
go func() {
for range ticker.C {
for {
go func() {
// Attempt to probe the configured target.
success, dur := m.prober.Probe(timeout)
@ -32,6 +32,7 @@ func (m monitor) start(logger blog.Logger) {
logger.Infof(
"kind=[%s] success=[%v] duration=[%f] name=[%s]",
m.prober.Kind(), success, dur.Seconds(), m.prober.Name())
}
}()
}()
<-ticker.C
}
}