From 75ab7c9e9b19e28031ead76fb3f261379333634a Mon Sep 17 00:00:00 2001 From: Kevin Leimkuhler Date: Wed, 20 Feb 2019 13:26:20 -0800 Subject: [PATCH] trace: Allow `Span` IDs to be converted back to `u64`s (#910) ## Motivation As described in #905, subscribers have no way to get the numeric value of a span ID back _out_ of a `Span`. ## Solution Add a `Span::into_u64` method that returns the inner `u64` span ID Closes #905 Signed-off-by: kleimkuhler --- tokio-trace/tokio-trace-core/src/span.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tokio-trace/tokio-trace-core/src/span.rs b/tokio-trace/tokio-trace-core/src/span.rs index 1ad66a554..7b93d8d69 100644 --- a/tokio-trace/tokio-trace-core/src/span.rs +++ b/tokio-trace/tokio-trace-core/src/span.rs @@ -2,7 +2,7 @@ /// Identifies a span within the context of a process. /// -/// Span IDs are used primarily to determine of two handles refer to the same +/// Span IDs are used primarily to determine if two handles refer to the same /// span, without requiring the comparison of the span's fields. /// /// They are generated by [`Subscriber`](::Subscriber)s for each span as it is @@ -19,4 +19,9 @@ impl Span { pub fn from_u64(u: u64) -> Self { Span(u) } + + /// Returns the span's ID as a `u64`. + pub fn into_u64(&self) -> u64 { + self.0 + } }