Skip to content

Commit 3aa6f8d

Browse files
committed
Remove async from force_flush in LogExporter
1 parent 125af29 commit 3aa6f8d

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

opentelemetry-sdk/src/export/logs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub trait LogExporter: Send + Sync + Debug {
107107
/// implemented as a blocking API or an asynchronous API which notifies the caller via
108108
/// a callback or an event. OpenTelemetry client authors can decide if they want to
109109
/// make the flush timeout configurable.
110-
async fn force_flush(&mut self) -> ExportResult {
110+
fn force_flush(&mut self) -> ExportResult {
111111
Ok(())
112112
}
113113
/// Set the resource for the exporter.

opentelemetry-sdk/src/logs/log_processor.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl<R: RuntimeChannel> BatchLogProcessor<R> {
259259
logs.split_off(0),
260260
)
261261
.await
262-
.and(exporter.as_mut().force_flush().await);
262+
.and(exporter.as_mut().force_flush());
263263

264264
if let Some(channel) = res_channel {
265265
if let Err(send_error) = channel.send(result) {
@@ -779,6 +779,25 @@ mod tests {
779779
let _ = provider.shutdown();
780780
}
781781

782+
#[tokio::test(flavor = "multi_thread")]
783+
async fn test_batch_forceflush() {
784+
let exporter = InMemoryLogExporterBuilder::default().build();
785+
// TODO: Verify exporter.force_flush() is called
786+
787+
let processor = BatchLogProcessor::new(
788+
Box::new(exporter.clone()),
789+
BatchConfig::default(),
790+
runtime::Tokio,
791+
);
792+
793+
let mut record = LogRecord::default();
794+
let instrumentation = InstrumentationScope::default();
795+
796+
processor.emit(&mut record, &instrumentation);
797+
processor.force_flush().unwrap();
798+
assert_eq!(1, exporter.get_emitted_logs().unwrap().len());
799+
}
800+
782801
#[tokio::test(flavor = "multi_thread")]
783802
async fn test_batch_shutdown() {
784803
// assert we will receive an error
@@ -796,7 +815,6 @@ mod tests {
796815
let instrumentation = InstrumentationScope::default();
797816

798817
processor.emit(&mut record, &instrumentation);
799-
processor.force_flush().unwrap();
800818
processor.shutdown().unwrap();
801819
// todo: expect to see errors here. How should we assert this?
802820
processor.emit(&mut record, &instrumentation);

0 commit comments

Comments
 (0)