Skip to main content

TraceRing

Struct TraceRing 

Source
pub struct TraceRing { /* private fields */ }
Expand description

有界 trace 事件环(FIFO,满了丢最旧)。

Implementations§

Source§

impl TraceRing

Source

pub fn new(capacity: usize) -> Self

建一个容量为 capacity 条的环。每条 TraceEvent 40 字节,故 capacity 直接决定 内存上限(如 4096 条 ≈ 160 KB)。引擎只在 trace_capacity > 0 时构造,但本构造器是 公开 API,故 0 按 1 处理 —— 关键是任何输入下都必须有界。

Source

pub fn record( &self, node: u32, phase: TracePhase, start_us: i64, dur_us: i64, input_ts: i64, )

记一条 span。满了丢最旧。线程号在本环内稳定分配(首次见到某线程即给一个递增小整数)。

Source

pub fn snapshot(&self) -> Vec<TraceEvent>

当前环内容的快照(不清空:环自身有界,可多次导出)。

Source

pub fn clear(&self)

清空(供图 reset 重跑;事件、线程号映射一并归零,容量不变)。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.