From 375048ded2a4263b775c4cc0638830f8ffe45bb9 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 20 Jan 2021 10:29:48 -0500 Subject: [PATCH 1/2] Drop the span on future completion, not drop --- zipkin/src/open_span.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/zipkin/src/open_span.rs b/zipkin/src/open_span.rs index c0c628c..8b713a0 100644 --- a/zipkin/src/open_span.rs +++ b/zipkin/src/open_span.rs @@ -185,7 +185,10 @@ impl OpenSpan { where F: Future, { - Bind { span: self, future } + Bind { + span: Some(self), + future, + } } } @@ -193,9 +196,9 @@ pin_project! { /// A type which wraps a future, associating it with an `OpenSpan`. /// /// The span's context will be set as the current whenever it's polled, and the span will close - /// when the future is dropped. + /// when the future completes. pub struct Bind { - span: OpenSpan, + span: Option>, #[pin] future: T, } @@ -209,7 +212,18 @@ where fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { let this = self.project(); - let _guard = crate::set_current(this.span.context()); - this.future.poll(cx) + let _guard = crate::set_current( + this.span + .as_ref() + .expect("future polled after completion") + .context(), + ); + + let r = this.future.poll(cx); + if r.is_ready() { + *this.span = None; + } + + r } } From 06d922b2c58aa9074f29f260d66e8ff1548f70fa Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 20 Jan 2021 10:35:29 -0500 Subject: [PATCH 2/2] Release zipkin 0.4.2 --- zipkin/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zipkin/Cargo.toml b/zipkin/Cargo.toml index 806f2e3..bc6e1dc 100644 --- a/zipkin/Cargo.toml +++ b/zipkin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zipkin" -version = "0.4.1" +version = "0.4.2" authors = ["Steven Fackler "] edition = "2018" license = "Apache-2.0"