Skip to content

Commit a0e5061

Browse files
utpillacijothomasTommyCpp
authored
Update documentation for Metrics API (#2280)
Co-authored-by: Cijo Thomas <[email protected]> Co-authored-by: Zhongyang Wu <[email protected]>
1 parent 927a08c commit a0e5061

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

opentelemetry/src/global/metrics.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ fn global_meter_provider() -> &'static RwLock<GlobalMeterProvider> {
1515

1616
/// Sets the given [`MeterProvider`] instance as the current global meter
1717
/// provider.
18+
///
19+
/// **NOTE:** This function should be called before getting [`Meter`] instances via [`meter()`] or [`meter_with_scope()`]. Otherwise, you could get no-op [`Meter`] instances.
1820
pub fn set_meter_provider<P>(new_provider: P)
1921
where
2022
P: metrics::MeterProvider + Send + Sync + 'static,
@@ -44,6 +46,9 @@ pub fn meter_provider() -> GlobalMeterProvider {
4446
/// Creates a named [`Meter`] via the currently configured global [`MeterProvider`].
4547
///
4648
/// This is a more convenient way of expressing `global::meter_provider().meter(name)`.
49+
///
50+
/// **NOTE:** Calls to [`meter()`] return a [`Meter`] backed by the global [`MeterProvider`] configured during the method invocation.
51+
/// If the global [`MeterProvider`] is changed after getting [`Meter`] instances from these calls, the [`Meter`] instances returned will not reflect the change.
4752
pub fn meter(name: &'static str) -> Meter {
4853
meter_provider().meter(name)
4954
}
@@ -52,6 +57,9 @@ pub fn meter(name: &'static str) -> Meter {
5257
///
5358
/// This is a simpler alternative to `global::meter_provider().meter_with_scope(...)`
5459
///
60+
/// **NOTE:** Calls to [`meter_with_scope()`] return a [`Meter`] backed by the global [`MeterProvider`] configured during the method invocation.
61+
/// If the global [`MeterProvider`] is changed after getting [`Meter`] instances from these calls, the [`Meter`] instances returned will not reflect the change.
62+
///
5563
/// # Example
5664
///
5765
/// ```

0 commit comments

Comments
 (0)