tracing_perfetto_sdk_schema

Struct TracePacket

Source
pub struct TracePacket {
Show 13 fields pub timestamp: Option<u64>, pub timestamp_clock_id: Option<u32>, pub trusted_pid: Option<i32>, pub interned_data: Option<InternedData>, pub sequence_flags: Option<u32>, pub incremental_state_cleared: Option<bool>, pub trace_packet_defaults: Option<TracePacketDefaults>, pub previous_packet_dropped: Option<bool>, pub first_packet_on_sequence: Option<bool>, pub machine_id: Option<u32>, pub data: Option<Data>, pub optional_trusted_uid: Option<OptionalTrustedUid>, pub optional_trusted_packet_sequence_id: Option<OptionalTrustedPacketSequenceId>,
}
Expand description

TracePacket is the root object of a Perfetto trace. A Perfetto trace is a linear sequence of TracePacket(s).

The tracing service guarantees that all TracePacket(s) written by a given TraceWriter are seen in-order, without gaps or duplicates. If, for any reason, a TraceWriter sequence becomes invalid, no more packets are returned to the Consumer (or written into the trace file). TracePacket(s) written by different TraceWriter(s), hence even different data sources, can be seen in arbitrary order. The consumer can re-establish a total order, if interested, using the packet timestamps, after having synchronized the different clocks onto a global clock.

The tracing service is agnostic of the content of TracePacket, with the exception of few fields (e.g.. trusted_*, trace_config) that are written by the service itself.

See the Buffers and Dataflow doc for details.

Next reserved id: 14 (up to 15). Next id: 113.

Fields§

§timestamp: Option<u64>

The timestamp of the TracePacket. By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on Android). It can be overridden using a different timestamp_clock_id. The clock domain definition in ClockSnapshot can also override:

  • The unit (default: 1ns).
  • The absolute vs delta encoding (default: absolute timestamp).
§timestamp_clock_id: Option<u32>

Specifies the ID of the clock used for the TracePacket |timestamp|. Can be one of the built-in types from ClockSnapshot::BuiltinClocks, or a producer-defined clock id. If unspecified and if no default per-sequence value has been provided via TracePacketDefaults, it defaults to BuiltinClocks::BOOTTIME.

§trusted_pid: Option<i32>

Trusted process id of the producer which generated this packet, written by the service.

§interned_data: Option<InternedData>

Incrementally emitted interned data, valid only on the packet’s sequence (packets with the same |trusted_packet_sequence_id|). The writer will usually emit new interned data in the same TracePacket that first refers to it (since the last reset of interning state). It may also be emitted proactively in advance of referring to them in later packets.

§sequence_flags: Option<u32>§incremental_state_cleared: Option<bool>

DEPRECATED. Moved to SequenceFlags::SEQ_INCREMENTAL_STATE_CLEARED.

§trace_packet_defaults: Option<TracePacketDefaults>

Default values for fields of later TracePackets emitted on this packet’s sequence (TracePackets with the same |trusted_packet_sequence_id|). It must be reemitted when incremental state is cleared (see |incremental_state_cleared|). Requires that any future packet emitted on the same sequence specifies the SEQ_NEEDS_INCREMENTAL_STATE flag. TracePacketDefaults always override the global defaults for any future packet on this sequence (regardless of SEQ_NEEDS_INCREMENTAL_STATE).

§previous_packet_dropped: Option<bool>

Flag set by the service if, for the current packet sequence (see |trusted_packet_sequence_id|), either:

  • this is the first packet, or
  • one or multiple packets were dropped since the last packet that the consumer read from the sequence. This can happen if chunks in the trace buffer are overridden before the consumer could read them when the trace is configured in ring buffer mode.

When packet loss occurs, incrementally emitted data (including interned data) on the sequence should be considered invalid up until the next packet with SEQ_INCREMENTAL_STATE_CLEARED set.

§first_packet_on_sequence: Option<bool>

Flag set by a producer (starting from SDK v29) if, for the current packet sequence (see |trusted_packet_sequence_id|), this is the first packet.

This flag can be used for distinguishing the two situations when processing the trace:

  1. There are no prior events for the sequence because of data loss, e.g. due to ring buffer wrapping.
  2. There are no prior events for the sequence because it didn’t start before this packet (= there’s definitely no preceding data loss).

Given that older SDK versions do not support this flag, this flag not being present for a particular sequence does not necessarily imply data loss.

§machine_id: Option<u32>

The machine ID for identifying trace packets in a multi-machine tracing session. Is emitted by the tracing service for producers running on a remote host (e.g. a VM guest). For more context: go/crosetto-vm-tracing.

§data: Option<Data>§optional_trusted_uid: Option<OptionalTrustedUid>

Trusted user id of the producer which generated this packet. Keep in sync with TrustedPacket.trusted_uid.

TODO(eseckler): Emit this field in a PacketSequenceDescriptor message instead.

§optional_trusted_packet_sequence_id: Option<OptionalTrustedPacketSequenceId>

Service-assigned identifier of the packet sequence this packet belongs to. Uniquely identifies a producer + writer pair within the tracing session. A value of zero denotes an invalid ID. Keep in sync with TrustedPacket.trusted_packet_sequence_id.

Implementations§

Source§

impl TracePacket

Source

pub fn timestamp(&self) -> u64

Returns the value of timestamp, or the default value if timestamp is unset.

Source

pub fn sequence_flags(&self) -> u32

Returns the value of sequence_flags, or the default value if sequence_flags is unset.

Source

pub fn incremental_state_cleared(&self) -> bool

Returns the value of incremental_state_cleared, or the default value if incremental_state_cleared is unset.

Source

pub fn previous_packet_dropped(&self) -> bool

Returns the value of previous_packet_dropped, or the default value if previous_packet_dropped is unset.

Source

pub fn timestamp_clock_id(&self) -> u32

Returns the value of timestamp_clock_id, or the default value if timestamp_clock_id is unset.

Source

pub fn trusted_pid(&self) -> i32

Returns the value of trusted_pid, or the default value if trusted_pid is unset.

Source

pub fn first_packet_on_sequence(&self) -> bool

Returns the value of first_packet_on_sequence, or the default value if first_packet_on_sequence is unset.

Source

pub fn machine_id(&self) -> u32

Returns the value of machine_id, or the default value if machine_id is unset.

Trait Implementations§

Source§

impl Clone for TracePacket

Source§

fn clone(&self) -> TracePacket

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TracePacket

Source§

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

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

impl Default for TracePacket

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Message for TracePacket

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
where B: BufMut, Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
where B: Buf, Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
where B: Buf, Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for TracePacket

Source§

fn eq(&self, other: &TracePacket) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TracePacket

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.