pub struct TraceRing { /* private fields */ }Expand description
有界 trace 事件环(FIFO,满了丢最旧)。
Implementations§
Source§impl TraceRing
impl TraceRing
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
建一个容量为 capacity 条的环。每条 TraceEvent 40 字节,故 capacity 直接决定
内存上限(如 4096 条 ≈ 160 KB)。引擎只在 trace_capacity > 0 时构造,但本构造器是
公开 API,故 0 按 1 处理 —— 关键是任何输入下都必须有界。
Sourcepub fn record(
&self,
node: u32,
phase: TracePhase,
start_us: i64,
dur_us: i64,
input_ts: i64,
)
pub fn record( &self, node: u32, phase: TracePhase, start_us: i64, dur_us: i64, input_ts: i64, )
记一条 span。满了丢最旧。线程号在本环内稳定分配(首次见到某线程即给一个递增小整数)。
Sourcepub fn snapshot(&self) -> Vec<TraceEvent>
pub fn snapshot(&self) -> Vec<TraceEvent>
当前环内容的快照(不清空:环自身有界,可多次导出)。
Auto Trait Implementations§
impl !Freeze for TraceRing
impl RefUnwindSafe for TraceRing
impl Send for TraceRing
impl Sync for TraceRing
impl Unpin for TraceRing
impl UnsafeUnpin for TraceRing
impl UnwindSafe for TraceRing
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more