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. ATraceRow::TimestampBaserow 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: TTimestamp
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.
Enter
A span has been entered. This means it is spending CPU time now.
Fields
ts: TTimestamp
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: TTimestamp
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: TTimestamp
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
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: TTimestamp
memory_pressure: u8OS memory pressure in 0..=100 (from
TurboMalloc::memory_pressure()). 0 is used when the current
platform does not report a pressure value.
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.
Implementations§
Source§impl<'a, T> TraceRow<'a, T>
impl<'a, T> TraceRow<'a, T>
Sourcepub fn timestamp(&self) -> Option<&T>
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.
Sourcepub fn map_timestamp<U>(self, f: impl FnOnce(T) -> U) -> TraceRow<'a, U>
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.
Sourcepub fn try_map_timestamp<U, E>(
self,
f: impl FnOnce(T) -> Result<U, E>,
) -> Result<TraceRow<'a, U>, E>
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.