mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 23:19:06 +01:00
Fix: When sending metrics failed the batch size could be exceeded
This commit is contained in:
parent
b732b2d739
commit
580d21d8bb
@ -142,17 +142,20 @@ func (s *InfluxSink) Flush() error {
|
||||
|
||||
// Send metrics from batch slice
|
||||
err := s.writeApi.WritePoint(context.Background(), s.batch...)
|
||||
if err != nil {
|
||||
cclog.ComponentError(s.name, "flush failed:", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Clear batch slice
|
||||
// (when sending the metrics failed, metrics get dropped and are lost)
|
||||
for i := range s.batch {
|
||||
s.batch[i] = nil
|
||||
}
|
||||
s.batch = s.batch[:0]
|
||||
|
||||
// Report errors for sending metrics
|
||||
if err != nil {
|
||||
cclog.ComponentError(s.name, "flush failed:", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user