mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-26 15:29:04 +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
|
// Send metrics from batch slice
|
||||||
err := s.writeApi.WritePoint(context.Background(), s.batch...)
|
err := s.writeApi.WritePoint(context.Background(), s.batch...)
|
||||||
if err != nil {
|
|
||||||
cclog.ComponentError(s.name, "flush failed:", err.Error())
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear batch slice
|
// Clear batch slice
|
||||||
|
// (when sending the metrics failed, metrics get dropped and are lost)
|
||||||
for i := range s.batch {
|
for i := range s.batch {
|
||||||
s.batch[i] = nil
|
s.batch[i] = nil
|
||||||
}
|
}
|
||||||
s.batch = s.batch[:0]
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user