Skip to content

Commit 5ce50ae

Browse files
authored
simplify async trait impl (open-telemetry#2692)
1 parent 37efb88 commit 5ce50ae

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

opentelemetry-sdk/src/logs/log_processor.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,8 @@ pub(crate) mod tests {
8888
}
8989

9090
impl LogExporter for MockLogExporter {
91-
#[allow(clippy::manual_async_fn)]
92-
fn export(
93-
&self,
94-
_batch: LogBatch<'_>,
95-
) -> impl std::future::Future<Output = OTelSdkResult> + Send {
96-
async { Ok(()) }
91+
async fn export(&self, _batch: LogBatch<'_>) -> OTelSdkResult {
92+
Ok(())
9793
}
9894

9995
fn shutdown(&mut self) -> OTelSdkResult {

opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,8 @@ mod tests {
317317
}
318318

319319
impl LogExporter for MockLogExporter {
320-
#[allow(clippy::manual_async_fn)]
321-
fn export(
322-
&self,
323-
_batch: LogBatch<'_>,
324-
) -> impl std::future::Future<Output = OTelSdkResult> + Send {
325-
async { Ok(()) }
320+
async fn export(&self, _batch: LogBatch<'_>) -> OTelSdkResult {
321+
Ok(())
326322
}
327323

328324
fn shutdown(&mut self) -> OTelSdkResult {

opentelemetry-sdk/src/logs/simple_log_processor.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,14 @@ mod tests {
168168
}
169169

170170
impl LogExporter for LogExporterThatRequiresTokio {
171-
#[allow(clippy::manual_async_fn)]
172-
fn export(
173-
&self,
174-
batch: LogBatch<'_>,
175-
) -> impl std::future::Future<Output = OTelSdkResult> + Send {
171+
async fn export(&self, batch: LogBatch<'_>) -> OTelSdkResult {
176172
// Simulate minimal dependency on tokio by sleeping asynchronously for a short duration
177-
async move {
178-
tokio::time::sleep(Duration::from_millis(50)).await;
173+
tokio::time::sleep(Duration::from_millis(50)).await;
179174

180-
for _ in batch.iter() {
181-
self.export_count.fetch_add(1, Ordering::Acquire);
182-
}
183-
Ok(())
175+
for _ in batch.iter() {
176+
self.export_count.fetch_add(1, Ordering::Acquire);
184177
}
178+
Ok(())
185179
}
186180
}
187181

0 commit comments

Comments
 (0)