This commit is contained in:
Sebastien Blot 2024-04-22 17:58:09 +02:00
parent 3169343526
commit e36d2cb6b8
No known key found for this signature in database
GPG key ID: DFC2902F40449F6A

View file

@ -328,25 +328,21 @@ func (a *apic) SendUsageMetrics() {
metrics, metricsId, err := a.GetUsageMetrics()
if err != nil {
log.Errorf("unable to get usage metrics: %s", err)
continue
}
/*jsonStr, err := json.Marshal(metrics)
if err != nil {
log.Errorf("unable to marshal usage metrics (%s)", err)
}*/
//fmt.Printf("Usage metrics: %s\n", string(jsonStr))
_, _, err = a.apiClient.UsageMetrics.Add(context.Background(), metrics)
if err != nil {
log.Errorf("unable to send usage metrics: %s", err)
} else {
err = a.MarkUsageMetricsAsSent(metricsId)
if err != nil {
log.Errorf("unable to mark usage metrics as sent: %s", err)
} else {
log.Infof("Usage metrics sent")
}
continue
}
err = a.MarkUsageMetricsAsSent(metricsId)
if err != nil {
log.Errorf("unable to mark usage metrics as sent: %s", err)
continue
}
log.Infof("Usage metrics sent")
}
}
}