@@ -20,17 +20,14 @@ use super::{
2020 data:: ResourceMetrics , instrument:: InstrumentKind , reader:: MetricReader , Pipeline , Temporality ,
2121} ;
2222
23- const DEFAULT_TIMEOUT : Duration = Duration :: from_secs ( 30 ) ;
2423const DEFAULT_INTERVAL : Duration = Duration :: from_secs ( 60 ) ;
2524
2625const METRIC_EXPORT_INTERVAL_NAME : & str = "OTEL_METRIC_EXPORT_INTERVAL" ;
27- const METRIC_EXPORT_TIMEOUT_NAME : & str = "OTEL_METRIC_EXPORT_TIMEOUT" ;
2826
2927/// Configuration options for [PeriodicReader].
3028#[ derive( Debug ) ]
3129pub struct PeriodicReaderBuilder < E > {
3230 interval : Duration ,
33- timeout : Duration ,
3431 exporter : E ,
3532}
3633
4340 . ok ( )
4441 . and_then ( |v| v. parse ( ) . map ( Duration :: from_millis) . ok ( ) )
4542 . unwrap_or ( DEFAULT_INTERVAL ) ;
46- let timeout = env:: var ( METRIC_EXPORT_TIMEOUT_NAME )
47- . ok ( )
48- . and_then ( |v| v. parse ( ) . map ( Duration :: from_millis) . ok ( ) )
49- . unwrap_or ( DEFAULT_TIMEOUT ) ;
5043
51- PeriodicReaderBuilder {
52- interval,
53- timeout,
54- exporter,
55- }
44+ PeriodicReaderBuilder { interval, exporter }
5645 }
5746
5847 /// Configures the intervening time between exports for a [PeriodicReader].
6958 self
7059 }
7160
72- /// Configures the timeout for an export to complete. PeriodicReader itself
73- /// does not enforce timeout. Instead timeout is passed on to the exporter
74- /// for each export attempt.
75- ///
76- /// This option overrides any value set for the `OTEL_METRIC_EXPORT_TIMEOUT`
77- /// environment variable.
78- ///
79- /// If this option is not used or `timeout` is equal to zero, 30 seconds is used
80- /// as the default.
81- pub fn with_timeout ( mut self , timeout : Duration ) -> Self {
82- if !timeout. is_zero ( ) {
83- self . timeout = timeout;
84- }
85- self
86- }
87-
8861 /// Create a [PeriodicReader] with the given config.
8962 pub fn build ( self ) -> PeriodicReader {
90- PeriodicReader :: new ( self . exporter , self . interval , self . timeout )
63+ PeriodicReader :: new ( self . exporter , self . interval )
9164 }
9265}
9366
@@ -165,7 +138,7 @@ impl PeriodicReader {
165138 PeriodicReaderBuilder :: new ( exporter)
166139 }
167140
168- fn new < E > ( exporter : E , interval : Duration , timeout : Duration ) -> Self
141+ fn new < E > ( exporter : E , interval : Duration ) -> Self
169142 where
170143 E : PushMetricExporter ,
171144 {
@@ -189,7 +162,6 @@ impl PeriodicReader {
189162 otel_info ! (
190163 name: "PeriodReaderThreadStarted" ,
191164 interval_in_millisecs = interval. as_millis( ) ,
192- timeout_in_millisecs = timeout. as_millis( )
193165 ) ;
194166 loop {
195167 otel_debug ! (
@@ -200,8 +172,7 @@ impl PeriodicReader {
200172 otel_debug ! (
201173 name: "PeriodReaderThreadExportingDueToFlush"
202174 ) ;
203-
204- let export_result = cloned_reader. collect_and_export ( timeout) ;
175+ let export_result = cloned_reader. collect_and_export ( ) ;
205176 otel_debug ! (
206177 name: "PeriodReaderInvokedExport" ,
207178 export_result = format!( "{:?}" , export_result)
@@ -257,7 +228,7 @@ impl PeriodicReader {
257228 Ok ( Message :: Shutdown ( response_sender) ) => {
258229 // Perform final export and break out of loop and exit the thread
259230 otel_debug ! ( name: "PeriodReaderThreadExportingDueToShutdown" ) ;
260- let export_result = cloned_reader. collect_and_export ( timeout ) ;
231+ let export_result = cloned_reader. collect_and_export ( ) ;
261232 otel_debug ! (
262233 name: "PeriodReaderInvokedExport" ,
263234 export_result = format!( "{:?}" , export_result)
@@ -305,7 +276,7 @@ impl PeriodicReader {
305276 name: "PeriodReaderThreadExportingDueToTimer"
306277 ) ;
307278
308- let export_result = cloned_reader. collect_and_export ( timeout ) ;
279+ let export_result = cloned_reader. collect_and_export ( ) ;
309280 otel_debug ! (
310281 name: "PeriodReaderInvokedExport" ,
311282 export_result = format!( "{:?}" , export_result)
@@ -357,8 +328,8 @@ impl PeriodicReader {
357328 reader
358329 }
359330
360- fn collect_and_export ( & self , timeout : Duration ) -> OTelSdkResult {
361- self . inner . collect_and_export ( timeout )
331+ fn collect_and_export ( & self ) -> OTelSdkResult {
332+ self . inner . collect_and_export ( )
362333 }
363334}
364335
@@ -402,23 +373,18 @@ impl PeriodicReaderInner {
402373 }
403374 }
404375
405- fn collect_and_export ( & self , timeout : Duration ) -> OTelSdkResult {
376+ fn collect_and_export ( & self ) -> OTelSdkResult {
406377 // TODO: Reuse the internal vectors. Or refactor to avoid needing any
407378 // owned data structures to be passed to exporters.
408379 let mut rm = ResourceMetrics {
409380 resource : Resource :: empty ( ) ,
410381 scope_metrics : Vec :: new ( ) ,
411382 } ;
412383
413- // Measure time taken for collect, and subtract it from the timeout.
414384 let current_time = Instant :: now ( ) ;
415385 let collect_result = self . collect ( & mut rm) ;
416386 let time_taken_for_collect = current_time. elapsed ( ) ;
417- let _timeout = if time_taken_for_collect > timeout {
418- Duration :: from_secs ( 0 )
419- } else {
420- timeout - time_taken_for_collect
421- } ;
387+
422388 #[ allow( clippy:: question_mark) ]
423389 if let Err ( e) = collect_result {
424390 otel_warn ! (
0 commit comments