Avoid sending nil body with metrics (#2470)
This commit is contained in:
parent
64deeab1ec
commit
d5b6f2974b
1 changed files with 8 additions and 5 deletions
|
@ -129,12 +129,15 @@ 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)
|
||||
}
|
||||
log.Info("capi metrics: sending")
|
||||
_, _, err = a.apiClient.Metrics.Add(context.Background(), metrics)
|
||||
if err != nil {
|
||||
log.Errorf("capi metrics: failed: %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?
|
||||
|
|
Loading…
Reference in a new issue