@@ -12,9 +12,8 @@ use futures_util::{
1212 StreamExt ,
1313} ;
1414use opentelemetry:: {
15- global,
1615 metrics:: { MetricsError , Result } ,
17- otel_error,
16+ otel_debug , otel_error,
1817} ;
1918
2019use crate :: runtime:: Runtime ;
@@ -245,34 +244,39 @@ impl<RT: Runtime> PeriodicReaderWorker<RT> {
245244 Either :: Left ( ( res, _) ) => {
246245 res // return the status of export.
247246 }
248- Either :: Right ( _) => {
249- otel_error ! (
250- name: "collect_and_export" ,
251- status = "timed_out"
252- ) ;
253- Err ( MetricsError :: Other ( "export timed out" . into ( ) ) )
254- }
247+ Either :: Right ( _) => Err ( MetricsError :: Other ( "export timed out" . into ( ) ) ) ,
255248 }
256249 }
257250
258251 async fn process_message ( & mut self , message : Message ) -> bool {
259252 match message {
260253 Message :: Export => {
261254 if let Err ( err) = self . collect_and_export ( ) . await {
262- global:: handle_error ( err)
255+ otel_error ! (
256+ name: "PeriodicReader.ExportFailed" ,
257+ message = "Failed to export metrics" ,
258+ reason = format!( "{}" , err) ) ;
263259 }
264260 }
265261 Message :: Flush ( ch) => {
266262 let res = self . collect_and_export ( ) . await ;
267- if ch. send ( res) . is_err ( ) {
268- global:: handle_error ( MetricsError :: Other ( "flush channel closed" . into ( ) ) )
263+ if let Err ( send_error) = ch. send ( res) {
264+ otel_debug ! (
265+ name: "PeriodicReader.Flush.SendResultError" ,
266+ message = "Failed to send flush result" ,
267+ reason = format!( "{:?}" , send_error) ,
268+ ) ;
269269 }
270270 }
271271 Message :: Shutdown ( ch) => {
272272 let res = self . collect_and_export ( ) . await ;
273273 let _ = self . reader . exporter . shutdown ( ) ;
274- if ch. send ( res) . is_err ( ) {
275- global:: handle_error ( MetricsError :: Other ( "shutdown channel closed" . into ( ) ) )
274+ if let Err ( send_error) = ch. send ( res) {
275+ otel_debug ! (
276+ name: "PeriodicReader.Shutdown.SendResultError" ,
277+ message = "Failed to send shutdown result" ,
278+ reason = format!( "{:?}" , send_error) ,
279+ ) ;
276280 }
277281 return false ;
278282 }
@@ -300,9 +304,8 @@ impl MetricReader for PeriodicReader {
300304 let worker = match & mut inner. sdk_producer_or_worker {
301305 ProducerOrWorker :: Producer ( _) => {
302306 // Only register once. If producer is already set, do nothing.
303- global:: handle_error ( MetricsError :: Other (
304- "duplicate meter registration, did not register manual reader" . into ( ) ,
305- ) ) ;
307+ otel_debug ! ( name: "PeriodicReader.DuplicateRegistration" ,
308+ message = "duplicate registration found, did not register periodic reader." ) ;
306309 return ;
307310 }
308311 ProducerOrWorker :: Worker ( w) => mem:: replace ( w, Box :: new ( |_| { } ) ) ,
0 commit comments