Skip to content

Commit 034d853

Browse files
committed
Update documentation for Metrics API
1 parent 31bea19 commit 034d853

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

opentelemetry/src/global/metrics.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ static GLOBAL_METER_PROVIDER: Lazy<RwLock<GlobalMeterProvider>> =
1111

1212
/// Sets the given [`MeterProvider`] instance as the current global meter
1313
/// provider.
14+
///
15+
/// **Note:** This function should be called before getting [`Meter`] instances via [`meter()`] or [`meter_with_scope()`]. Otherwise, you could get no-op [`Meter`] instances.
1416
pub fn set_meter_provider<P>(new_provider: P)
1517
where
1618
P: metrics::MeterProvider + Send + Sync + 'static,
@@ -34,14 +36,20 @@ pub fn meter_provider() -> GlobalMeterProvider {
3436
/// If the name is an empty string, the provider will use a default name.
3537
///
3638
/// This is a more convenient way of expressing `global::meter_provider().meter(name)`.
39+
///
40+
/// **Note:** Calls to [`meter()`] return a [`Meter`] backed by the global [`MeterProvider`] configured during the method invocation.
41+
/// If the global [`MeterProvider`] is changed after getting [`Meter`] instances from these calls, the [`Meter`] instances returned will not reflect the change.
3742
pub fn meter(name: &'static str) -> Meter {
3843
meter_provider().meter(name)
3944
}
4045

4146
/// Creates a [`Meter`] with the given instrumentation scope.
4247
///
4348
/// This is a simpler alternative to `global::meter_provider().meter_with_scope(...)`
44-
///
49+
///
50+
/// **Note:** Calls to [`meter_with_scope()`] 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.
52+
///
4553
/// # Example
4654
///
4755
/// ```

0 commit comments

Comments
 (0)