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