summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEliza Weisman <eliza@buoyant.io>2019-03-11 17:08:04 -0700
committerGitHub <noreply@github.com>2019-03-11 17:08:04 -0700
commit46149f031e406e43fe4ca4d0d3f0ad9e036e2768 (patch)
tree0deb5ad0551f078767db72ebf0566da797a892c0
parent5510ba6dbae3de69d7f69d3a3f1b4bc1e1e179e0 (diff)
trace-core: Fix `NoSubscriber` causing panics (#975)
PR #973 changed the `tokio_trace_core::span::Id::from_u64` function to require that the provided `u64` be greater than zero. However, I had forgotten that the implementation of `Subscriber` for the `NoSubscriber` type (which is used when no default subscriber is set) always returned `span::Id::from_u64(0)` from its `new_span` method. In combination with the assert added in #973, this means that every time a span is hit when no subscriber is set, `tokio-trace-core` will panic. This branch fixes the panics by having `NoSubscriber` construct span IDs using a different (arbitrarily chosen) non-zero constant. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
-rw-r--r--tokio-trace/tokio-trace-core/src/dispatcher.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/tokio-trace/tokio-trace-core/src/dispatcher.rs b/tokio-trace/tokio-trace-core/src/dispatcher.rs
index 590980c4..840a9e66 100644
--- a/tokio-trace/tokio-trace-core/src/dispatcher.rs
+++ b/tokio-trace/tokio-trace-core/src/dispatcher.rs
@@ -252,7 +252,7 @@ impl Subscriber for NoSubscriber {
}
fn new_span(&self, _: &span::Attributes) -> span::Id {
- span::Id::from_u64(0)
+ span::Id::from_u64(0xDEAD)
}
fn event(&self, _event: &Event) {}