From e209a282d92d25304850494807d42ecc7b5e14f2 Mon Sep 17 00:00:00 2001 From: "Aode (lion)" Date: Mon, 6 Dec 2021 21:11:43 -0600 Subject: [PATCH] No more follows-from for process --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/process.rs | 28 +++++++++++++--------------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b672bc..fdd52e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1347,7 +1347,7 @@ dependencies = [ [[package]] name = "pict-rs" -version = "0.3.0-beta.10" +version = "0.3.0-beta.11" dependencies = [ "actix-form-data", "actix-rt", diff --git a/Cargo.toml b/Cargo.toml index 931e8a2..94d1e58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "pict-rs" description = "A simple image hosting service" -version = "0.3.0-beta.10" +version = "0.3.0-beta.11" authors = ["asonix "] license = "AGPL-3.0" readme = "README.md" diff --git a/src/process.rs b/src/process.rs index 1363730..057d809 100644 --- a/src/process.rs +++ b/src/process.rs @@ -45,18 +45,22 @@ impl Process { fn spawn_span(&self) -> Span { let span = tracing::info_span!(parent: None, "Spawned command writer",); + span.follows_from(self.span.clone()); + span } - #[tracing::instrument(name = "Spawning Command")] pub(crate) fn spawn(cmd: &mut Command) -> std::io::Result { let cmd = cmd.stdin(Stdio::piped()).stdout(Stdio::piped()); - cmd.spawn().map(|child| Process { - child, - span: Span::current(), - }) + let span = tracing::info_span!( + "Spawning Command", + command = &tracing::field::debug(&cmd), + exception.message = &tracing::field::Empty, + exception.details = &tracing::field::Empty, + ); + cmd.spawn().map(|child| Process { child, span }) } pub(crate) async fn wait(mut self) -> std::io::Result<()> { @@ -100,7 +104,7 @@ impl Process { Some(ProcessRead { inner: stdout, - span: body_span(self.span), + span: self.span, err_recv: rx, err_closed: false, handle: DropHandle { inner: handle }, @@ -133,7 +137,7 @@ impl Process { Some(ProcessRead { inner: stdout, - span: body_span(self.span), + span: self.span, err_recv: rx, err_closed: false, handle: DropHandle { inner: handle }, @@ -177,7 +181,7 @@ impl Process { Some(ProcessRead { inner: stdout, - span: body_span(self.span), + span: self.span, err_recv: rx, err_closed: false, handle: DropHandle { inner: handle }, @@ -185,12 +189,6 @@ impl Process { } } -fn body_span(following: Span) -> Span { - let span = tracing::info_span!(parent: None, "Processing Command"); - span.follows_from(following); - span -} - impl AsyncRead for ProcessRead where I: AsyncRead, @@ -202,10 +200,10 @@ where ) -> Poll> { let this = self.as_mut().project(); + let span = this.span; let err_recv = this.err_recv; let err_closed = this.err_closed; let inner = this.inner; - let span = this.span; span.in_scope(|| { if !*err_closed {