mirror of
				https://github.com/ClusterCockpit/cc-metric-collector.git
				synced 2025-10-31 17:05:07 +01:00 
			
		
		
		
	Fix: When sending metrics failed the batch size could be exceeded
This commit is contained in:
		| @@ -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 | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user