Expand description
Per-component CPU-time measurement primitives.
This module provides the building blocks for attributing CPU time to individual Vector components at runtime:
ThreadTime— a lightweight snapshot of thread CPU time, backed byCLOCK_THREAD_CPUTIME_IDon Linux/macOS,GetThreadTimeson Windows, and a zero no-op on other platforms.CpuTimedFuture/CpuTimedExt— aFutureadapter that brackets everypollcall with aThreadTimesample and accumulates the delta into a [metrics::Counter].spawn_timed— convenience wrapper that spawns a future on the current tokio runtime with optional CPU-time accounting attached.register_counter— registers thecomponent_cpu_usage_ns_totalmetrics counter for a component (available on Linux, macOS, and Windows only).
Structs§
- CpuTimed
Future - A
Futureadapter that accumulates thread CPU time across everypoll. - Thread
Time - An opaque snapshot of thread CPU time.
Traits§
- CpuTimed
Ext - Extension trait that wraps a future in
CpuTimedFuturevia a chained call:
Functions§
- register_
counter - Registers the
component_cpu_usage_ns_totalcounter for the calling component on platforms where thread CPU time is available (Linux, macOS, Windows). On other platforms it returns [Counter::noop()] — the metric is not emitted at all, rather than reporting wall-clock or zero values that would be misleading to compare against supported platforms. - spawn_
timed - Spawns
futureon the current tokio runtime, attaching CPU-time accounting whencounterisSome. WhenNone, the future is spawned as-is with no per-poll overhead.