@@ -19,6 +19,8 @@ namespace OpenCensus.Trace.Export
1919 using System ;
2020 using System . Collections . Concurrent ;
2121 using System . Collections . Generic ;
22+ using System . Threading ;
23+ using System . Threading . Tasks ;
2224 using OpenCensus . Common ;
2325 using OpenCensus . Implementation ;
2426
@@ -54,6 +56,25 @@ internal void AddSpan(ISpan span)
5456 }
5557 }
5658
59+ internal Task ExportAsync ( IEnumerable < ISpanData > export , CancellationToken token )
60+ {
61+ var handlers = this . serviceHandlers . Values ;
62+ foreach ( var handler in handlers )
63+ {
64+ try
65+ {
66+ // TODO: when handlers interface will be switched to async - this need to await
67+ handler . Export ( export ) ;
68+ }
69+ catch ( Exception ex )
70+ {
71+ OpenCensusEventSource . Log . ExporterThrownExceptionWarning ( ex ) ;
72+ }
73+ }
74+
75+ return Task . CompletedTask ;
76+ }
77+
5778 internal void Run ( object obj )
5879 {
5980 List < ISpanData > toExport = new List < ISpanData > ( ) ;
@@ -67,7 +88,7 @@ internal void Run(object obj)
6788 this . BuildList ( item , toExport ) ;
6889
6990 // Export them
70- this . Export ( toExport ) ;
91+ this . ExportAsync ( toExport , CancellationToken . None ) ;
7192
7293 // Get ready for next batch
7394 toExport . Clear ( ) ;
@@ -128,21 +149,5 @@ private void BuildList(ISpan item, List<ISpanData> toExport)
128149 }
129150 }
130151 }
131-
132- private void Export ( IEnumerable < ISpanData > export )
133- {
134- var handlers = this . serviceHandlers . Values ;
135- foreach ( var handler in handlers )
136- {
137- try
138- {
139- handler . Export ( export ) ;
140- }
141- catch ( Exception ex )
142- {
143- OpenCensusEventSource . Log . ExporterThrownExceptionWarning ( ex ) ;
144- }
145- }
146- }
147152 }
148153}
0 commit comments