Struct Builder
pub struct Builder<PID, EXP, TIME, THREAD> {
process_id: Option<ProcessId>,
exporter: Option<&'static (dyn Export + Sync)>,
timestamp_fn: Option<fn() -> u64>,
thread_id_fn: Option<fn() -> NonZero<u64>>,
_pid: PhantomData<PID>,
_exp: PhantomData<EXP>,
_time: PhantomData<TIME>,
_thread: PhantomData<THREAD>,
}Expand description
Builder for initializing the telemetry collector.
Uses type-state pattern to ensure all required components are configured at compile time.
Created via build() and finalized with set_global().
Fields§
§process_id: Option<ProcessId>§exporter: Option<&'static (dyn Export + Sync)>§timestamp_fn: Option<fn() -> u64>§thread_id_fn: Option<fn() -> NonZero<u64>>§_pid: PhantomData<PID>§_exp: PhantomData<EXP>§_time: PhantomData<TIME>§_thread: PhantomData<THREAD>Implementations§
§impl<PID, EXP, TIME, THREAD> Builder<PID, EXP, TIME, THREAD>
impl<PID, EXP, TIME, THREAD> Builder<PID, EXP, TIME, THREAD>
pub fn process_id(
self,
process_id: ProcessId,
) -> Builder<WithProcessId, EXP, TIME, THREAD>
pub fn process_id( self, process_id: ProcessId, ) -> Builder<WithProcessId, EXP, TIME, THREAD>
Sets the process id for this collector instance.
pub fn exporter(
self,
exporter: &'static (dyn Export + Sync),
) -> Builder<PID, WithExporter, TIME, THREAD>
pub fn exporter( self, exporter: &'static (dyn Export + Sync), ) -> Builder<PID, WithExporter, TIME, THREAD>
Sets the exporter for telemetry data.
pub fn time<T>(self) -> Builder<PID, EXP, WithTime, THREAD>where
T: TimeAbstraction,
pub fn time<T>(self) -> Builder<PID, EXP, WithTime, THREAD>where
T: TimeAbstraction,
Configures the time abstraction to use (monotonic time only).
pub fn system_time<T>(self) -> Builder<PID, EXP, WithTime, THREAD>where
T: TimeAbstraction + SystemTime,
pub fn system_time<T>(self) -> Builder<PID, EXP, WithTime, THREAD>where
T: TimeAbstraction + SystemTime,
Configures the time abstraction with system time to use (Unix epoch synchronization).
pub fn thread<Th>(self) -> Builder<PID, EXP, TIME, WithThread>where
Th: ThreadAbstraction,
pub fn thread<Th>(self) -> Builder<PID, EXP, TIME, WithThread>where
Th: ThreadAbstraction,
Configures the thread abstraction to use.
§impl<EXP, TIME, THREAD> Builder<NoProcessId, EXP, TIME, THREAD>
impl<EXP, TIME, THREAD> Builder<NoProcessId, EXP, TIME, THREAD>
pub fn random_process_id(self) -> Builder<WithProcessId, EXP, TIME, THREAD>
Available on crate feature std only.
pub fn random_process_id(self) -> Builder<WithProcessId, EXP, TIME, THREAD>
std only.Sets a randomly generated process id.
Equivalent to .process_id(ProcessId::random(&mut rand::rng())).
§Examples
use veecle_osal_std::{time::Time, thread::Thread};
use veecle_telemetry::collector;
collector::build()
.random_process_id()
.exporter(exporter)
.time::<Time>()
.thread::<Thread>()
.set_global().unwrap();§impl<PID, TIME, THREAD> Builder<PID, NoExporter, TIME, THREAD>
impl<PID, TIME, THREAD> Builder<PID, NoExporter, TIME, THREAD>
pub fn leaked_exporter(
self,
exporter: impl Export + Sync + 'static,
) -> Builder<PID, WithExporter, TIME, THREAD>
Available on crate feature alloc only.
pub fn leaked_exporter( self, exporter: impl Export + Sync + 'static, ) -> Builder<PID, WithExporter, TIME, THREAD>
alloc only.Sets the given exporter by leaking it to obtain a static reference.
This is a convenience method for dynamic exporters that need to be boxed
and leaked. Equivalent to .exporter(Box::leak(Box::new(exporter))).
§Examples
use veecle_osal_std::{time::Time, thread::Thread};
use veecle_telemetry::collector::TestExporter;
let (exporter, _collected) = TestExporter::new();
veecle_telemetry::collector::build()
.random_process_id()
.leaked_exporter(exporter)
.time::<Time>()
.thread::<Thread>()
.set_global().unwrap();pub fn console_json_exporter(self) -> Builder<PID, WithExporter, TIME, THREAD>
Available on crate feature std only.
pub fn console_json_exporter(self) -> Builder<PID, WithExporter, TIME, THREAD>
std only.Sets the exporter to be the ConsoleJsonExporter.
Equivalent to .exporter(&ConsoleJsonExporter::DEFAULT).
§Examples
use veecle_osal_std::{time::Time, thread::Thread};
use veecle_telemetry::collector;
collector::build()
.random_process_id()
.console_json_exporter()
.time::<Time>()
.thread::<Thread>()
.set_global().unwrap();