elfo_core/tracing/
mod.rs

1//! Includes `TraceId` and useful utilities around it.
2//! For more details see [The Actoromicon](https://actoromicon.rs/ch05-04-tracing.html).
3
4use std::cell::RefCell;
5
6use self::generator::{ChunkRegistry, Generator};
7
8pub use self::{trace_id::TraceId, validator::TraceIdValidator};
9
10impl TraceId {
11    /// Generates a new trace id according to [the schema](https://actoromicon.rs/ch05-04-tracing.html#traceid).
12    pub fn generate() -> Self {
13        GENERATOR.with(|cell| cell.borrow_mut().generate(&CHUNK_REGISTRY))
14    }
15}
16
17static CHUNK_REGISTRY: ChunkRegistry = ChunkRegistry::new(0);
18thread_local! {
19    static GENERATOR: RefCell<Generator> = RefCell::new(Generator::default());
20}
21
22mod generator;
23mod trace_id;
24mod validator;