@@ -45,7 +45,7 @@ use futures_util::{
4545 stream:: { self , FusedStream , FuturesUnordered } ,
4646 StreamExt as _,
4747} ;
48- use opentelemetry:: global ;
48+ use opentelemetry:: { otel_debug , otel_error } ;
4949use opentelemetry:: {
5050 trace:: { TraceError , TraceResult } ,
5151 Context ,
@@ -134,7 +134,10 @@ impl SpanProcessor for SimpleSpanProcessor {
134134 . and_then ( |mut exporter| futures_executor:: block_on ( exporter. export ( vec ! [ span] ) ) ) ;
135135
136136 if let Err ( err) = result {
137- global:: handle_error ( err) ;
137+ otel_error ! (
138+ name: "SimpleProcessor.OnEnd.Error" ,
139+ reason = format!( "{:?}" , err)
140+ ) ;
138141 }
139142 }
140143
@@ -246,7 +249,10 @@ impl<R: RuntimeChannel> SpanProcessor for BatchSpanProcessor<R> {
246249 let result = self . message_sender . try_send ( BatchMessage :: ExportSpan ( span) ) ;
247250
248251 if let Err ( err) = result {
249- global:: handle_error ( TraceError :: Other ( err. into ( ) ) ) ;
252+ otel_error ! (
253+ name: "BatchProcessor.OnEnd.Error" ,
254+ reason = format!( "{:?}" , TraceError :: Other ( err. into( ) ) )
255+ ) ;
250256 }
251257 }
252258
@@ -313,14 +319,21 @@ impl<R: RuntimeChannel> BatchSpanProcessorInternal<R> {
313319 let result = export_task. await ;
314320
315321 if let Some ( channel) = res_channel {
322+ // If a response channel is provided, attempt to send the export result through it.
316323 if let Err ( result) = channel. send ( result) {
317- global :: handle_error ( TraceError :: from ( format ! (
318- "failed to send flush result: {:?} ",
319- result
320- ) ) ) ;
324+ otel_debug ! (
325+ name : "BatchSpanProcessor.Flush.SendResultError ",
326+ reason = format! ( "{:?}" , result)
327+ ) ;
321328 }
322329 } else if let Err ( err) = result {
323- global:: handle_error ( err) ;
330+ // If no channel is provided and the export operation encountered an error,
331+ // log the error directly here.
332+ otel_error ! (
333+ name: "BatchSpanProcessor.Flush.ExportError" ,
334+ reason = format!( "{:?}" , err) ,
335+ message = "Failed during the export process"
336+ ) ;
324337 }
325338
326339 Ok ( ( ) )
@@ -354,7 +367,10 @@ impl<R: RuntimeChannel> BatchSpanProcessorInternal<R> {
354367 let export_task = self . export ( ) ;
355368 let task = async move {
356369 if let Err ( err) = export_task. await {
357- global:: handle_error ( err) ;
370+ otel_error ! (
371+ name: "BatchSpanProcessor.Export.Error" ,
372+ error = format!( "{}" , err)
373+ ) ;
358374 }
359375
360376 Ok ( ( ) )
0 commit comments