@@ -23,20 +23,11 @@ use crate::traces::{
2323/// - Spawning non-blocking flush tasks
2424/// - Awaiting pending flush handles with retry logic
2525/// - Performing blocking flushes (spawn + await)
26- ///
27- /// # Type Parameters
28- ///
29- /// * `TF` - Trace flusher type implementing `TraceFlusher`
30- /// * `SF` - Stats flusher type implementing `StatsFlusher`
31- pub struct FlushingService < TF , SF >
32- where
33- TF : TraceFlusher + Send + Sync + ' static ,
34- SF : StatsFlusher + Send + Sync + ' static ,
35- {
26+ pub struct FlushingService {
3627 // Flushers
3728 logs_flusher : LogsFlusher ,
38- trace_flusher : Arc < TF > ,
39- stats_flusher : Arc < SF > ,
29+ trace_flusher : Arc < TraceFlusher > ,
30+ stats_flusher : Arc < StatsFlusher > ,
4031 proxy_flusher : Arc < ProxyFlusher > ,
4132 metrics_flushers : Arc < TokioMutex < Vec < MetricsFlusher > > > ,
4233
@@ -47,17 +38,13 @@ where
4738 handles : FlushHandles ,
4839}
4940
50- impl < TF , SF > FlushingService < TF , SF >
51- where
52- TF : TraceFlusher + Send + Sync + ' static ,
53- SF : StatsFlusher + Send + Sync + ' static ,
54- {
41+ impl FlushingService {
5542 /// Creates a new `FlushingService` with the given flushers.
5643 #[ must_use]
5744 pub fn new (
5845 logs_flusher : LogsFlusher ,
59- trace_flusher : Arc < TF > ,
60- stats_flusher : Arc < SF > ,
46+ trace_flusher : Arc < TraceFlusher > ,
47+ stats_flusher : Arc < StatsFlusher > ,
6148 proxy_flusher : Arc < ProxyFlusher > ,
6249 metrics_flushers : Arc < TokioMutex < Vec < MetricsFlusher > > > ,
6350 metrics_aggr_handle : MetricsAggregatorHandle ,
@@ -135,11 +122,13 @@ where
135122 self . handles . metric_flush_handles . push ( handle) ;
136123 }
137124
138- // Spawn stats flush (fire-and-forget, no retry)
125+ // Spawn stats flush
139126 let sf = Arc :: clone ( & self . stats_flusher ) ;
140127 self . handles
141128 . stats_flush_handles
142- . push ( tokio:: spawn ( async move { sf. flush ( false ) . await } ) ) ;
129+ . push ( tokio:: spawn ( async move {
130+ sf. flush ( false , None ) . await . unwrap_or_default ( )
131+ } ) ) ;
143132
144133 // Spawn proxy flush
145134 let pf = self . proxy_flusher . clone ( ) ;
@@ -166,11 +155,25 @@ where
166155 let mut joinset = tokio:: task:: JoinSet :: new ( ) ;
167156 let mut flush_error = false ;
168157
169- // Await stats handles (no retry)
158+ // Await stats handles with retry
170159 for handle in self . handles . stats_flush_handles . drain ( ..) {
171- if let Err ( e) = handle. await {
172- error ! ( "FLUSHING_SERVICE | stats flush error {e:?}" ) ;
173- flush_error = true ;
160+ match handle. await {
161+ Ok ( retry) => {
162+ let sf = self . stats_flusher . clone ( ) ;
163+ if !retry. is_empty ( ) {
164+ debug ! (
165+ "FLUSHING_SERVICE | redriving {:?} stats payloads" ,
166+ retry. len( )
167+ ) ;
168+ joinset. spawn ( async move {
169+ sf. flush ( false , Some ( retry) ) . await ;
170+ } ) ;
171+ }
172+ }
173+ Err ( e) => {
174+ error ! ( "FLUSHING_SERVICE | stats flush error {e:?}" ) ;
175+ flush_error = true ;
176+ }
174177 }
175178 }
176179
@@ -325,7 +328,7 @@ where
325328 self . logs_flusher. flush( None ) ,
326329 futures:: future:: join_all( metrics_futures) ,
327330 self . trace_flusher. flush( None ) ,
328- self . stats_flusher. flush( force_stats) ,
331+ self . stats_flusher. flush( force_stats, None ) ,
329332 self . proxy_flusher. flush( None ) ,
330333 ) ;
331334 }
@@ -340,11 +343,7 @@ where
340343 }
341344}
342345
343- impl < TF , SF > std:: fmt:: Debug for FlushingService < TF , SF >
344- where
345- TF : TraceFlusher + Send + Sync + ' static ,
346- SF : StatsFlusher + Send + Sync + ' static ,
347- {
346+ impl std:: fmt:: Debug for FlushingService {
348347 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
349348 f. debug_struct ( "FlushingService" )
350349 . field ( "handles" , & self . handles )
0 commit comments