trace-core: Require span IDs to be > 0 (#973)

This branch changes `tokio_trace_core::span::Id::from_u64` to assert
that the integer from which the span ID is constructed is greater than
zero. This is to enable future use of non-zero optimization.

Unfortunately, we can't actually use a `NonZeroU64` _now_, as that type
was only stabilized in Rust 1.28.0, and `tokio`'s current minimum
supported Rust version is 1.26.0.

Adding and documenting the assertion now allows us to change the
internal representation to `NonZeroU64` later (when 1.28.0 is the
minimum supported Rust version), without causing a breaking change.

Signed-off-by: Eliza Weisman <[email protected]>
This commit is contained in:
Eliza Weisman
2019-03-11 16:18:40 -07:00
committed by GitHub
parent b8f63308d7
commit 5510ba6dba
2 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ where
spans: Mutex::new(HashMap::new()),
expected,
current: Mutex::new(Vec::new()),
ids: AtomicUsize::new(0),
ids: AtomicUsize::new(1),
filter: self.filter,
};
(subscriber, handle)