Skip to content

Commit 86d95fc

Browse files
authored
[*] fix switching standby and primary metrics, closes #814 (#815)
move the `hostLastKnownStatusInRecovery[monitoredSource.Name] = monitoredSource.IsInRecovery` update to after the processing of the last cached value
1 parent 1581ee1 commit 86d95fc

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

internal/reaper/reaper.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ func (r *Reaper) Reap(ctx context.Context) {
112112
} else {
113113
metricsConfig = monitoredSource.Metrics
114114
}
115-
hostLastKnownStatusInRecovery[monitoredSource.Name] = monitoredSource.IsInRecovery
116115

117116
r.CreateSourceHelpers(ctx, srcL, monitoredSource)
118117

@@ -133,15 +132,14 @@ func (r *Reaper) Reap(ctx context.Context) {
133132
if monitoredSource.IsInRecovery && len(monitoredSource.MetricsStandby) > 0 {
134133
srcL.Warning("Switching metrics collection to standby config...")
135134
metricsConfig = monitoredSource.MetricsStandby
136-
hostLastKnownStatusInRecovery[monitoredSource.Name] = true
137-
} else {
135+
} else if !monitoredSource.IsInRecovery {
138136
srcL.Warning("Switching metrics collection to primary config...")
139137
metricsConfig = monitoredSource.Metrics
140-
hostLastKnownStatusInRecovery[monitoredSource.Name] = false
141138
}
139+
// else: it already has primary config do nothing + no warn
142140
}
143-
144141
}
142+
hostLastKnownStatusInRecovery[monitoredSource.Name] = monitoredSource.IsInRecovery
145143

146144
for metricName, interval := range metricsConfig {
147145
metric := metricName

0 commit comments

Comments
 (0)