Skip to main content

TraceRow

Enum TraceRow 

Source
pub enum TraceRow<'a, T = DeltaEncodedTimestamp> {
    Start {
        ts: T,
        id: u64,
        parent: Option<u64>,
        name: Cow<'a, str>,
        target: Cow<'a, str>,
        values: Vec<(Cow<'a, str>, TraceValue<'a>)>,
    },
    End {
        ts: T,
        id: u64,
    },
    Enter {
        ts: T,
        id: u64,
        thread_id: u64,
        allocations: Option<Allocations>,
    },
    Exit {
        ts: T,
        id: u64,
        thread_id: u64,
        allocations: Option<Allocations>,
    },
    Event {
        ts: T,
        parent: Option<u64>,
        values: Vec<(Cow<'a, str>, TraceValue<'a>)>,
    },
    Record {
        id: u64,
        values: Vec<(Cow<'a, str>, TraceValue<'a>)>,
    },
    MemorySample {
        ts: T,
        memory: u64,
        memory_pressure: u8,
        memory_footprint: u64,
        active_worker_threads: u64,
    },
    TimestampBase {
        ts: u64,
    },
}
Expand description

A raw trace line.

§Timestamps

Timestamps are microseconds since the start of tracing. T is the type of the ts fields of all rows except TraceRow::TimestampBase:

  • TraceRow<'a> (T = DeltaEncodedTimestamp) is the serialized form. To keep the trace file small, every timestamp is the signed difference to the timestamp of the previous row with a timestamp in the trace stream (postcard zigzag encodes signed numbers, so small differences in both directions take few bytes). The differences can be negative, since rows are not necessarily in timestamp order. A TraceRow::TimestampBase row sets an absolute timestamp that the next difference refers to. The writer writes one before the first row with a timestamp in every thread local buffer, so the rows of each buffer can be decoded no matter where the buffer ends up in the file.
  • TraceRow<'a, u64> holds absolute timestamps.

Writers use a TimestampEncoder and readers a TimestampDecoder on every row in stream order to convert between the two forms.

Variants§

§

Start

A new span has been started, but not entered yet.

Fields

§ts: T

Timestamp

§id: u64

Unique id for this span.

§parent: Option<u64>

Id of the parent span, if any.

§name: Cow<'a, str>

The name of the span.

§target: Cow<'a, str>

The target of the span.

§values: Vec<(Cow<'a, str>, TraceValue<'a>)>

A list of key-value pairs for all attributes of the span.

§

End

A span has ended. The id might be reused in future.

Fields

§ts: T

Timestamp

§id: u64

Unique id for this span. Must be created by a Start event before.

§

Enter

A span has been entered. This means it is spending CPU time now.

Fields

§ts: T

Timestamp

§id: u64

Unique id for this span. Must be created by a Start event before.

§thread_id: u64

The thread id of the thread that entered the span.

§allocations: Option<Allocations>

What the thread (de)allocated since its previous Enter/Exit row, if anything and if memory is tracked. See Allocations.

§

Exit

A span has been exited. This means it is not spending CPU time anymore.

Fields

§ts: T

Timestamp

§id: u64

Unique id for this span. Must be entered by a Enter event before.

§thread_id: u64

The thread id of the thread that exits the span.

§allocations: Option<Allocations>

What the thread (de)allocated since its previous Enter/Exit row, if anything and if memory is tracked. See Allocations.

§

Event

A event has happened for some span.

Fields

§ts: T

Timestamp

§parent: Option<u64>

Id of the parent span, if any.

§values: Vec<(Cow<'a, str>, TraceValue<'a>)>

A list of key-value pairs for all attributes of the event.

§

Record

Additional fields for a span

Fields

§id: u64

Unique id for this span. Must be created by a Start event before.

§values: Vec<(Cow<'a, str>, TraceValue<'a>)>

A list of key-value pairs for all attributes of the span.

§

MemorySample

A snapshot of process memory and non-idle Tokio scheduler workers.

Fields

§ts: T

Timestamp

§memory: u64

Memory usage in bytes (from TurboMalloc::memory_usage())

§memory_pressure: u8

OS memory pressure in 0..=100 (from TurboMalloc::memory_pressure()). 0 is used when the current platform does not report a pressure value.

§memory_footprint: u64

Process memory footprint in bytes (from TurboMalloc::memory_footprint()). 0 is used when the current platform does not report a value. The footprint is refreshed at most about once per second; samples in between repeat the last reading.

§active_worker_threads: u64

Number of non-parked Tokio scheduler worker threads in this process.

§

TimestampBase

Sets the absolute timestamp that the ts of the next row with a timestamp is relative to. See “Timestamps” in the docs of TraceRow. Only meaningful in the serialized form.

Fields

§ts: u64

Absolute timestamp

Implementations§

Source§

impl<'a, T> TraceRow<'a, T>

Source

pub fn timestamp(&self) -> Option<&T>

The timestamp of this row, if it has one. This doesn’t include TraceRow::TimestampBase, which only defines the base for other timestamps.

Source

pub fn map_timestamp<U>(self, f: impl FnOnce(T) -> U) -> TraceRow<'a, U>

Converts the timestamp of this row (if it has one) with f, keeping everything else.

Source

pub fn try_map_timestamp<U, E>( self, f: impl FnOnce(T) -> Result<U, E>, ) -> Result<TraceRow<'a, U>, E>

Like TraceRow::map_timestamp, but the conversion can fail.

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for TraceRow<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de: 'a, 'a, T> Deserialize<'de> for TraceRow<'a, T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a, T> Serialize for TraceRow<'a, T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for TraceRow<'a, T>
where T: Freeze,

§

impl<'a, T> RefUnwindSafe for TraceRow<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for TraceRow<'a, T>
where T: Send,

§

impl<'a, T> Sync for TraceRow<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for TraceRow<'a, T>
where T: Unpin,

§

impl<'a, T> UnsafeUnpin for TraceRow<'a, T>
where T: UnsafeUnpin,

§

impl<'a, T> UnwindSafe for TraceRow<'a, T>
where T: UnwindSafe,

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more