From 034d8530f5305e693e5a21b63691e0d1e1eabccf Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:32:04 +0000 Subject: [PATCH 1/3] Update documentation for Metrics API --- opentelemetry/src/global/metrics.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/opentelemetry/src/global/metrics.rs b/opentelemetry/src/global/metrics.rs index 142a5c2f69..fa0aee9b26 100644 --- a/opentelemetry/src/global/metrics.rs +++ b/opentelemetry/src/global/metrics.rs @@ -11,6 +11,8 @@ static GLOBAL_METER_PROVIDER: Lazy> = /// 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

(new_provider: P) where P: metrics::MeterProvider + Send + Sync + 'static, @@ -34,6 +36,9 @@ pub fn meter_provider() -> GlobalMeterProvider { /// If the name is an empty string, the provider will use a default name. /// /// 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) } @@ -41,7 +46,10 @@ pub fn meter(name: &'static str) -> Meter { /// Creates a [`Meter`] with the given instrumentation scope. /// /// 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 /// /// ``` From 6fa881cd74c7140cf8df19ae32cf888479a69a17 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:34:22 +0000 Subject: [PATCH 2/3] Code changes --- opentelemetry/src/global/metrics.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opentelemetry/src/global/metrics.rs b/opentelemetry/src/global/metrics.rs index fa0aee9b26..9fbf2c0cac 100644 --- a/opentelemetry/src/global/metrics.rs +++ b/opentelemetry/src/global/metrics.rs @@ -12,7 +12,7 @@ static GLOBAL_METER_PROVIDER: Lazy> = /// 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. +/// **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

(new_provider: P) where P: metrics::MeterProvider + Send + Sync + 'static, @@ -37,7 +37,7 @@ pub fn meter_provider() -> GlobalMeterProvider { /// /// 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. +/// **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) @@ -47,7 +47,7 @@ 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. +/// **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 From 43a456f4bc851b0a6ecbc6ca16375eafe5b69ee3 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:41:55 +0000 Subject: [PATCH 3/3] Fix CI --- opentelemetry/src/global/metrics.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opentelemetry/src/global/metrics.rs b/opentelemetry/src/global/metrics.rs index 9fbf2c0cac..58e63f793b 100644 --- a/opentelemetry/src/global/metrics.rs +++ b/opentelemetry/src/global/metrics.rs @@ -11,7 +11,7 @@ static GLOBAL_METER_PROVIDER: Lazy> = /// 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

(new_provider: P) where @@ -36,7 +36,7 @@ pub fn meter_provider() -> GlobalMeterProvider { /// If the name is an empty string, the provider will use a default name. /// /// 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 { @@ -46,10 +46,10 @@ pub fn meter(name: &'static str) -> Meter { /// Creates a [`Meter`] with the given instrumentation scope. /// /// 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 /// /// ```