Skip to content

make force_flush() in PushMetricExporter synchronous #2663

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

Merged
merged 6 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
self.client.export(metrics).await
}

async fn force_flush(&self) -> OTelSdkResult {
fn force_flush(&self) -> OTelSdkResult {

Check warning on line 147 in opentelemetry-otlp/src/metric.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/metric.rs#L147

Added line #L147 was not covered by tests
// this component is stateless
Ok(())
}
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## vNext

- *Breaking* Make `force_flush()` in `PushMetricExporter` synchronous

## 0.28.0

Released 2025-Feb-10
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait PushMetricExporter: Send + Sync + 'static {
) -> impl std::future::Future<Output = OTelSdkResult> + Send;

/// Flushes any metric data held by an exporter.
fn force_flush(&self) -> impl std::future::Future<Output = OTelSdkResult> + Send;
fn force_flush(&self) -> OTelSdkResult;

/// Releases any held computational resources.
///
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/metrics/in_memory_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
.map_err(|_| OTelSdkError::InternalFailure("Failed to lock metrics".to_string()))
}

async fn force_flush(&self) -> OTelSdkResult {
fn force_flush(&self) -> OTelSdkResult {

Check warning on line 275 in opentelemetry-sdk/src/metrics/in_memory_exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/in_memory_exporter.rs#L275

Added line #L275 was not covered by tests
Ok(()) // In this implementation, flush does nothing
}

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/metrics/periodic_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@
}
}

async fn force_flush(&self) -> OTelSdkResult {
fn force_flush(&self) -> OTelSdkResult {

Check warning on line 560 in opentelemetry-sdk/src/metrics/periodic_reader.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/periodic_reader.rs#L560

Added line #L560 was not covered by tests
Ok(())
}

Expand All @@ -580,7 +580,7 @@
Ok(())
}

async fn force_flush(&self) -> OTelSdkResult {
fn force_flush(&self) -> OTelSdkResult {

Check warning on line 583 in opentelemetry-sdk/src/metrics/periodic_reader.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/periodic_reader.rs#L583

Added line #L583 was not covered by tests
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-stdout/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
}
}

async fn force_flush(&self) -> OTelSdkResult {
fn force_flush(&self) -> OTelSdkResult {

Check warning on line 61 in opentelemetry-stdout/src/metrics/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-stdout/src/metrics/exporter.rs#L61

Added line #L61 was not covered by tests
// exporter holds no state, nothing to flush
Ok(())
}
Expand Down