File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1313 *)  
1414module  D  =  Debug. Make  (struct  let  name =  " tracing" end )
1515
16+ module  Delay  =  Xapi_stdext_threads.Threadext. Delay 
1617open  D 
1718
1819type  endpoint  = Bugtool  | Url  of  Uri .t 
@@ -803,19 +804,30 @@ module Export = struct
803804      |>  List. concat_map (fun  x  -> TracerProvider. get_endpoints x)
804805      |>  List. iter (export_to_endpoint parent span_list)
805806
807+     let  delay =  Delay. make () 
808+ 
809+     (*  Note this signal will flush the spans and terminate the exporter thread *) 
810+     let  signal  ()  =  Delay. signal delay
811+ 
806812    let  main  ()  = 
807813      enable_span_garbage_collector ()  ;
808814      Thread. create
809815        (fun  ()  ->
810816          while  true  do 
811817            debug " Tracing: Waiting %d seconds before exporting spans" 
812818              (int_of_float ! export_interval) ;
813-             Thread. delay ! export_interval ;
819+             if  not  (Delay. wait delay ! export_interval) then  (
820+               debug " Tracing: we are signaled, export spans now and exit" 
821+               flush_spans ()  ;
822+               raise Thread. Exit 
823+             ) ;
814824            flush_spans () 
815825          done 
816826        )
817827        () 
818828  end 
819829end 
820830
831+ let  flush_and_exit =  Export.Destination. signal
832+ 
821833let  main =  Export.Destination. main
Original file line number Diff line number Diff line change @@ -152,4 +152,6 @@ val set_observe : bool -> unit
152152
153153val  validate_attribute  : string  *  string  -> bool 
154154
155+ val  flush_and_exit  : unit  -> unit 
156+ 
155157val  main  : unit  -> Thread .t 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments