Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old global meter provider shutdown method #1412

Merged
merged 5 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions opentelemetry-sdk/src/metrics/meter_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,31 @@ impl SdkMeterProvider {
/// use opentelemetry_sdk::metrics::SdkMeterProvider;
///
/// fn init_metrics() -> SdkMeterProvider {
/// // Setup metric pipelines with readers + views, default has no
/// // readers so nothing is exported.
/// let provider = SdkMeterProvider::default();
///
/// // Set provider to be used as global meter provider
/// let _ = global::set_meter_provider(provider.clone());
///
/// // Setup metric pipelines with readers + views
///
/// provider
/// }
///
/// fn main() {
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let provider = init_metrics();
///
/// // create instruments + record measurements
///
/// // force all instruments to flush
/// provider.force_flush().unwrap();
/// provider.force_flush()?;
///
/// // record more measurements..
///
/// // dropping provider and shutting down global provider ensure all
/// // remaining metrics data are exported
/// drop(provider);
/// global::shutdown_meter_provider();
/// // shutdown ensures any cleanup required by the provider is done,
/// // and also invokes shutdown on the readers.
/// provider.shutdown()?;
///
/// Ok(())
/// }
/// ```
pub fn force_flush(&self) -> Result<()> {
Expand Down
3 changes: 2 additions & 1 deletion opentelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ of entries, so moving from `IndexMap` to `HashMap` offers slight performance
gains, and avoids `IndexMap` dependency. This affects `body` and `attributes` of
`LogRecord`.
[#1353](https://github.com/open-telemetry/opentelemetry-rust/pull/1353)

- Add `TextMapCompositePropagator` [#1373](https://github.com/open-telemetry/opentelemetry-rust/pull/1373)
- Remove `global::shutdown_meter_provider`, use `SdkMeterProvider::shutdown`
jtescher marked this conversation as resolved.
Show resolved Hide resolved
directly instead (#1412).

### Removed

Expand Down
8 changes: 0 additions & 8 deletions opentelemetry/src/global/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ where
*global_provider = GlobalMeterProvider::new(new_provider);
}

/// Shut down the current meter global meter provider.
cijothomas marked this conversation as resolved.
Show resolved Hide resolved
pub fn shutdown_meter_provider() {
let mut global_provider = GLOBAL_METER_PROVIDER
.write()
.expect("GLOBAL_METER_PROVIDER RwLock poisoned");
*global_provider = GlobalMeterProvider::new(metrics::noop::NoopMeterProvider::new());
}

/// Returns an instance of the currently configured global [`MeterProvider`]
/// through [`GlobalMeterProvider`].
pub fn meter_provider() -> GlobalMeterProvider {
Expand Down
Loading