@@ -91,25 +91,50 @@ where
9191 }
9292}
9393
94- /// A [MetricReader] that continuously collects and exports metrics at a set
95- /// interval.
94+ /// A `MetricReader` that periodically collects and exports metrics at a configurable interval.
9695///
97- /// By default, `PeriodicReader` will collect and export metrics every 60
98- /// seconds. The export time is not counted towards the interval between
99- /// attempts. `PeriodicReader` itself does not enforce a timeout. Instead, the
100- /// timeout is passed on to the configured exporter for each export attempt.
96+ /// By default, [`PeriodicReader`] collects and exports metrics every **60 seconds**.
97+ /// The time taken for export is **not** included in the interval. Use [`PeriodicReaderBuilder`]
98+ /// to customize the interval.
10199///
102- /// `PeriodicReader` spawns a background thread to handle the periodic
103- /// collection and export of metrics. The background thread will continue to run
104- /// until `shutdown()` is called.
100+ /// [`PeriodicReader`] spawns a background thread to handle metric collection and export.
101+ /// This thread remains active until [`shutdown()`] is called.
105102///
106- /// When using this reader with the OTLP Exporter, the following exporter
107- /// features are supported:
108- /// - `grpc-tonic`: This requires `MeterProvider` to be created within a tokio
109- /// runtime.
110- /// - `reqwest-blocking-client`: Works with a regular `main` or `tokio::main`.
103+ /// ## Collection Process
104+ /// "Collection" refers to gathering aggregated metrics from the SDK's internal storage.
105+ /// During this phase, callbacks from observable instruments are also triggered.
111106///
112- /// In other words, other clients like `reqwest` and `hyper` are not supported.
107+ /// [`PeriodicReader`] does **not** enforce a timeout for collection. If an
108+ /// observable callback takes too long, it may delay the next collection cycle.
109+ /// If a callback never returns, it **will stall** all metric collection (and exports)
110+ /// indefinitely.
111+ ///
112+ /// ## Exporter Compatibility
113+ /// When used with the [`OTLP Exporter`](https://docs.rs/opentelemetry-otlp), the following
114+ /// transport options are supported:
115+ ///
116+ /// - **`grpc-tonic`**: Requires [`MeterProvider`] to be initialized within a `tokio` runtime.
117+ /// - **`reqwest-blocking-client`**: Works with both a standard (`main`) function and `tokio::main`.
118+ ///
119+ /// [`PeriodicReader`] does **not** enforce a timeout for exports either. Instead,
120+ /// the configured exporter is responsible for enforcing timeouts. If an export operation
121+ /// never returns, [`PeriodicReader`] will **stop exporting new metrics**, stalling
122+ /// metric collection.
123+ ///
124+ /// ## Manual Export & Shutdown
125+ /// Users can manually trigger an export via [`force_flush()`]. Calling [`shutdown()`]
126+ /// exports any remaining metrics and should be done before application exit to ensure
127+ /// all data is sent.
128+ ///
129+ /// **Warning**: If using **tokio’s current-thread runtime**, calling [`shutdown()`]
130+ /// from the main thread may cause a deadlock. To prevent this, call [`shutdown()`]
131+ /// from a separate thread or use tokio's `spawn_blocking`.
132+ ///
133+ /// [`PeriodicReader`]: crate::metrics::PeriodicReader
134+ /// [`PeriodicReaderBuilder`]: crate::metrics::PeriodicReaderBuilder
135+ /// [`MeterProvider`]: crate::metrics::SdkMeterProvider
136+ /// [`shutdown()`]: crate::metrics::SdkMeterProvider::shutdown
137+ /// [`force_flush()`]: crate::metrics::SdkMeterProvider::force_flush
113138///
114139/// # Example
115140///
0 commit comments