Fix peering metrics bug (#15178)
This bug was caused by the peering health metric being set to NaN.
This commit is contained in:
parent
571fd7b6db
commit
57fb729547
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
peering: Fix a bug that resulted in /v1/agent/metrics returning an error.
|
||||||
|
```
|
|
@ -122,19 +122,14 @@ func (s *Server) emitPeeringMetricsOnce(metricsImpl *metrics.Metrics) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// peering health metric
|
// peering health metric
|
||||||
if status.NeverConnected {
|
healthy := 0
|
||||||
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKeyDeprecated, float32(math.NaN()), labels)
|
switch {
|
||||||
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKey, float32(math.NaN()), labels)
|
case status.NeverConnected:
|
||||||
} else {
|
case s.peerStreamServer.Tracker.IsHealthy(status):
|
||||||
healthy := s.peerStreamServer.Tracker.IsHealthy(status)
|
healthy = 1
|
||||||
healthyInt := 0
|
|
||||||
if healthy {
|
|
||||||
healthyInt = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKeyDeprecated, float32(healthyInt), labels)
|
|
||||||
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKey, float32(healthyInt), labels)
|
|
||||||
}
|
}
|
||||||
|
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKeyDeprecated, float32(healthy), labels)
|
||||||
|
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKey, float32(healthy), labels)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1445,7 +1444,7 @@ func TestLeader_PeeringMetrics_emitPeeringMetrics(t *testing.T) {
|
||||||
healthyMetric3, ok := intv.Gauges[keyHealthyMetric3]
|
healthyMetric3, ok := intv.Gauges[keyHealthyMetric3]
|
||||||
require.True(r, ok, fmt.Sprintf("did not find the key %q", keyHealthyMetric3))
|
require.True(r, ok, fmt.Sprintf("did not find the key %q", keyHealthyMetric3))
|
||||||
|
|
||||||
require.True(r, math.IsNaN(float64(healthyMetric3.Value)))
|
require.Equal(r, float32(0), healthyMetric3.Value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue