Skip to content

Commit

Permalink
feat: When tracing is enabled use the span from the scope of the run
Browse files Browse the repository at this point in the history
  • Loading branch information
uttarayan21 committed Feb 28, 2025
1 parent 4daae13 commit 560224b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mnn-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,13 @@ impl SessionHandle {
f: impl FnOnce(&mut SessionRunner) -> Result<R> + Send + Sync + 'static,
) -> Result<R> {
self.ensure_running()?;
#[cfg(features = "tracing")]
let span = tracing::Span::current();
let f = f;
let (tx, rx) = oneshot::channel();
let wrapped_f = move |sr: &mut SessionRunner| -> Result<()> {
#[cfg(features = "tracing")]
let _guard = span.enter();
let result = f(sr);
tx.send(result)
.change_context(ErrorKind::SyncError)
Expand All @@ -387,9 +391,13 @@ impl SessionHandle {
f: impl FnOnce(&mut SessionRunner) -> Result<R> + Send + Sync + 'static,
) -> Result<R> {
self.ensure_running()?;
#[cfg(features = "tracing")]
let span = tracing::Span::current();
let f = f;
let (tx, rx) = oneshot::channel();
let wrapped_f = move |sr: &mut SessionRunner| -> Result<()> {
#[cfg(features = "tracing")]
let _guard = span.enter();
let result = f(sr);
tx.send(result)
.change_context(ErrorKind::SyncError)
Expand Down

0 comments on commit 560224b

Please sign in to comment.