@@ -19,7 +19,8 @@ use crate::{
1919} ;
2020
2121use super :: {
22- meter:: SdkMeter , noop:: NoopMeter , pipeline:: Pipelines , reader:: MetricReader , view:: View ,
22+ exporter:: PushMetricExporter , meter:: SdkMeter , noop:: NoopMeter , pipeline:: Pipelines ,
23+ reader:: MetricReader , view:: View , PeriodicReader ,
2324} ;
2425
2526/// Handles the creation and coordination of [Meter]s.
@@ -244,14 +245,37 @@ impl MeterProviderBuilder {
244245 }
245246
246247 /// Associates a [MetricReader] with a [MeterProvider].
248+ /// [`MeterProviderBuilder::with_periodic_exporter()] can be used to add a PeriodicReader which is
249+ /// the most common use case.
247250 ///
248- /// By default, if this option is not used, the [MeterProvider] will perform no
249- /// operations; no data will be exported without a [MetricReader] .
251+ /// A [MeterProvider] will export no metrics without [MetricReader]
252+ /// added .
250253 pub fn with_reader < T : MetricReader > ( mut self , reader : T ) -> Self {
251254 self . readers . push ( Box :: new ( reader) ) ;
252255 self
253256 }
254257
258+ /// Adds a [`PushMetricExporter`] to the [`MeterProvider`] and configures it
259+ /// to export metrics at **fixed** intervals (60 seconds) using a
260+ /// [`PeriodicReader`].
261+ ///
262+ /// To customize the export interval, set the
263+ /// **"OTEL_METRIC_EXPORT_INTERVAL"** environment variable (in
264+ /// milliseconds).
265+ ///
266+ /// Most users should use this method to attach an exporter. Advanced users
267+ /// who need finer control over the export process can use
268+ /// [`crate::metrics::PeriodicReaderBuilder`] to configure a custom reader and attach it
269+ /// using [`MeterProviderBuilder::with_reader()`].
270+ pub fn with_periodic_exporter < T > ( mut self , exporter : T ) -> Self
271+ where
272+ T : PushMetricExporter ,
273+ {
274+ let reader = PeriodicReader :: builder ( exporter) . build ( ) ;
275+ self . readers . push ( Box :: new ( reader) ) ;
276+ self
277+ }
278+
255279 #[ cfg( feature = "spec_unstable_metrics_views" ) ]
256280 /// Associates a [View] with a [MeterProvider].
257281 ///
0 commit comments