@@ -12,9 +12,8 @@ use futures_util::{
12
12
StreamExt ,
13
13
} ;
14
14
use opentelemetry:: {
15
- global,
16
15
metrics:: { MetricsError , Result } ,
17
- otel_error,
16
+ otel_debug , otel_error,
18
17
} ;
19
18
20
19
use crate :: runtime:: Runtime ;
@@ -245,34 +244,39 @@ impl<RT: Runtime> PeriodicReaderWorker<RT> {
245
244
Either :: Left ( ( res, _) ) => {
246
245
res // return the status of export.
247
246
}
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 ( ) ) ) ,
255
248
}
256
249
}
257
250
258
251
async fn process_message ( & mut self , message : Message ) -> bool {
259
252
match message {
260
253
Message :: Export => {
261
254
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) ) ;
263
259
}
264
260
}
265
261
Message :: Flush ( ch) => {
266
262
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
+ ) ;
269
269
}
270
270
}
271
271
Message :: Shutdown ( ch) => {
272
272
let res = self . collect_and_export ( ) . await ;
273
273
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
+ ) ;
276
280
}
277
281
return false ;
278
282
}
@@ -300,9 +304,8 @@ impl MetricReader for PeriodicReader {
300
304
let worker = match & mut inner. sdk_producer_or_worker {
301
305
ProducerOrWorker :: Producer ( _) => {
302
306
// 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." ) ;
306
309
return ;
307
310
}
308
311
ProducerOrWorker :: Worker ( w) => mem:: replace ( w, Box :: new ( |_| { } ) ) ,
0 commit comments