Skip to content

Commit 4e5e77e

Browse files
gruebelcijothomaslalitb
committed
make force_flush() in PushMetricExporter synchronous (open-telemetry#2663)
Co-authored-by: Cijo Thomas <[email protected]> Co-authored-by: Lalit Kumar Bhasin <[email protected]>
1 parent 249e654 commit 4e5e77e

File tree

6 files changed

+8
-6
lines changed

6 files changed

+8
-6
lines changed

opentelemetry-otlp/src/metric.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl PushMetricExporter for MetricExporter {
143143
self.client.export(metrics).await
144144
}
145145

146-
async fn force_flush(&self) -> OTelSdkResult {
146+
fn force_flush(&self) -> OTelSdkResult {
147147
// this component is stateless
148148
Ok(())
149149
}

opentelemetry-sdk/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## vNext
44

5+
- *Breaking* Make `force_flush()` in `PushMetricExporter` synchronous
6+
57
- *Breaking (Affects custom Exporter/Processor/MetricReader authors only)* Removed
68
`opentelelemetry_sdk::logs::error::{LogError, LogResult}`. These were not
79
intended to be public. If you are authoring custom processor/exporters, use

opentelemetry-sdk/src/metrics/exporter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub trait PushMetricExporter: Send + Sync + 'static {
2020
) -> impl std::future::Future<Output = OTelSdkResult> + Send;
2121

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

2525
/// Releases any held computational resources.
2626
///

opentelemetry-sdk/src/metrics/in_memory_exporter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ impl PushMetricExporter for InMemoryMetricExporter {
272272
.map_err(|_| OTelSdkError::InternalFailure("Failed to lock metrics".to_string()))
273273
}
274274

275-
async fn force_flush(&self) -> OTelSdkResult {
275+
fn force_flush(&self) -> OTelSdkResult {
276276
Ok(()) // In this implementation, flush does nothing
277277
}
278278

opentelemetry-sdk/src/metrics/periodic_reader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ mod tests {
557557
}
558558
}
559559

560-
async fn force_flush(&self) -> OTelSdkResult {
560+
fn force_flush(&self) -> OTelSdkResult {
561561
Ok(())
562562
}
563563

@@ -580,7 +580,7 @@ mod tests {
580580
Ok(())
581581
}
582582

583-
async fn force_flush(&self) -> OTelSdkResult {
583+
fn force_flush(&self) -> OTelSdkResult {
584584
Ok(())
585585
}
586586

opentelemetry-stdout/src/metrics/exporter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl PushMetricExporter for MetricExporter {
5858
}
5959
}
6060

61-
async fn force_flush(&self) -> OTelSdkResult {
61+
fn force_flush(&self) -> OTelSdkResult {
6262
// exporter holds no state, nothing to flush
6363
Ok(())
6464
}

0 commit comments

Comments
 (0)