Avoid sending nil body with metrics (#2470)
This commit is contained in:
parent
64deeab1ec
commit
d5b6f2974b
|
@ -129,13 +129,16 @@ func (a *apic) SendMetrics(stop chan (bool)) {
|
|||
metTicker.Stop()
|
||||
metrics, err := a.GetMetrics()
|
||||
if err != nil {
|
||||
log.Errorf("unable to get metrics (%s), will retry", err)
|
||||
log.Errorf("unable to get metrics (%s)", err)
|
||||
}
|
||||
// metrics are nil if they could not be retrieved
|
||||
if metrics != nil {
|
||||
log.Info("capi metrics: sending")
|
||||
_, _, err = a.apiClient.Metrics.Add(context.Background(), metrics)
|
||||
if err != nil {
|
||||
log.Errorf("capi metrics: failed: %s", err)
|
||||
}
|
||||
}
|
||||
metTicker.Reset(nextMetInt())
|
||||
case <-a.metricsTomb.Dying(): // if one apic routine is dying, do we kill the others?
|
||||
checkTicker.Stop()
|
||||
|
|
Loading…
Reference in a new issue