-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use native Rust support for async traits in LogExporter::export() met…
…hod (11% improvement) (#2374) Co-authored-by: Cijo Thomas <[email protected]> Co-authored-by: Zhongyang Wu <[email protected]>
- Loading branch information
1 parent
80629c8
commit 23f6ae2
Showing
15 changed files
with
242 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,7 +209,6 @@ const fn severity_of_level(level: &Level) -> Severity { | |
#[cfg(test)] | ||
mod tests { | ||
use crate::layer; | ||
use async_trait::async_trait; | ||
use opentelemetry::logs::Severity; | ||
use opentelemetry::trace::TracerProvider as _; | ||
use opentelemetry::trace::{TraceContextExt, TraceFlags, Tracer}; | ||
|
@@ -245,13 +244,18 @@ mod tests { | |
#[derive(Clone, Debug, Default)] | ||
struct ReentrantLogExporter; | ||
|
||
#[async_trait] | ||
impl LogExporter for ReentrantLogExporter { | ||
async fn export(&self, _batch: LogBatch<'_>) -> LogResult<()> { | ||
// This will cause a deadlock as the export itself creates a log | ||
// while still within the lock of the SimpleLogProcessor. | ||
warn!(name: "my-event-name", target: "reentrant", event_id = 20, user_name = "otel", user_email = "[email protected]"); | ||
Ok(()) | ||
#[allow(clippy::manual_async_fn)] | ||
fn export( | ||
&self, | ||
_batch: LogBatch<'_>, | ||
) -> impl std::future::Future<Output = LogResult<()>> + Send { | ||
async { | ||
// This will cause a deadlock as the export itself creates a log | ||
// while still within the lock of the SimpleLogProcessor. | ||
warn!(name: "my-event-name", target: "reentrant", event_id = 20, user_name = "otel", user_email = "[email protected]"); | ||
Ok(()) | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.