Skip to content

Commit

Permalink
Update documentation for Metrics API (#2280)
Browse files Browse the repository at this point in the history
Co-authored-by: Cijo Thomas <[email protected]>
Co-authored-by: Zhongyang Wu <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2025
1 parent 927a08c commit a0e5061
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions opentelemetry/src/global/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ fn global_meter_provider() -> &'static RwLock<GlobalMeterProvider> {

/// Sets the given [`MeterProvider`] instance as the current global meter
/// provider.
///
/// **NOTE:** This function should be called before getting [`Meter`] instances via [`meter()`] or [`meter_with_scope()`]. Otherwise, you could get no-op [`Meter`] instances.
pub fn set_meter_provider<P>(new_provider: P)
where
P: metrics::MeterProvider + Send + Sync + 'static,
Expand Down Expand Up @@ -44,6 +46,9 @@ pub fn meter_provider() -> GlobalMeterProvider {
/// Creates a named [`Meter`] via the currently configured global [`MeterProvider`].
///
/// This is a more convenient way of expressing `global::meter_provider().meter(name)`.
///
/// **NOTE:** Calls to [`meter()`] return a [`Meter`] backed by the global [`MeterProvider`] configured during the method invocation.
/// If the global [`MeterProvider`] is changed after getting [`Meter`] instances from these calls, the [`Meter`] instances returned will not reflect the change.
pub fn meter(name: &'static str) -> Meter {
meter_provider().meter(name)
}
Expand All @@ -52,6 +57,9 @@ pub fn meter(name: &'static str) -> Meter {
///
/// This is a simpler alternative to `global::meter_provider().meter_with_scope(...)`
///
/// **NOTE:** Calls to [`meter_with_scope()`] return a [`Meter`] backed by the global [`MeterProvider`] configured during the method invocation.
/// If the global [`MeterProvider`] is changed after getting [`Meter`] instances from these calls, the [`Meter`] instances returned will not reflect the change.
///
/// # Example
///
/// ```
Expand Down

0 comments on commit a0e5061

Please sign in to comment.