Skip to main content

TraceEvent

Struct TraceEvent 

Source
#[repr(C)]
pub struct TraceEvent { pub ts_ns: u64, pub entity_id: u32, pub route_id: u32, pub span_id: u64, pub parent_span_id: u64, pub latency_us: u32, pub status_code: u16, pub error_code: u16, pub event_kind: u16, pub flags: u16, }
Expand description

A single observable trace point.

All fields are unsigned; the deserializer rejects negative literals. The constructors offered here are intentionally limited — callers should build events via the fixture synthesizer or by parsing canonical JSON, not by direct field assignment, so the bit-stability rules around field widths are honored automatically.

Fields§

§ts_ns: u64

Wall-clock timestamp, nanoseconds since the synthetic epoch (event 0). The pipeline derives the window index from this field via integer division by the contract’s window_size_ms * 1_000_000.

§entity_id: u32

The entity (service, process, sensor) the event belongs to. Bounded by n_entities in the contract.

§route_id: u32

The route within the entity (e.g. an HTTP endpoint or a sensor channel). Not used by the v0 pipeline for windowing but carried into the canonical bytes so the hash chain reflects the full fixture shape.

§span_id: u64

Tracing span identifier. Carried for fidelity of the catalog hash; not consumed by the residual/sign stages.

§parent_span_id: u64

Parent span identifier, or 0 for a root.

§latency_us: u32

Observed latency in microseconds. Clamped to contract.numeric.latency_clamp_ms * 1000 at the residual boundary to keep Q16.16 quantization in range.

§status_code: u16

HTTP-style status code (or a domain-specific equivalent). Carried through to the canonical bytes; the v0 pipeline checks for the error class via error_code not status_code.

§error_code: u16

Domain error code, with 0 meaning no error. Drives the error-rate derivative of the residual.

§event_kind: u16

Free-form event-type discriminator (request, response, log, sample). Not consumed in v0 but preserved in the catalog hash.

§flags: u16

Bit-field for miscellaneous flags (sampled, replayed, simulated). Preserved verbatim for the catalog hash.

Implementations§

Source§

impl TraceEvent

Source

pub const fn new( ts_ns: u64, entity_id: u32, route_id: u32, span_id: u64, parent_span_id: u64, latency_us: u32, status_code: u16, error_code: u16, event_kind: u16, flags: u16, ) -> Self

Construct a fully-specified TraceEvent. Used by the fixture synthesizer and tests. There is no builder pattern on purpose — the type is small enough that positional construction is more auditable than a fluent builder.

Source

pub const fn window_index(&self, window_size_ns: u64) -> u32

The window index this event falls into, given a window size in nanoseconds. Integer division; ties go to the lower window.

Trait Implementations§

Source§

impl Clone for TraceEvent

Source§

fn clone(&self) -> TraceEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TraceEvent

Source§

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

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

impl Default for TraceEvent

Source§

fn default() -> TraceEvent

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

impl Hash for TraceEvent

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TraceEvent

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Copy for TraceEvent

Source§

impl Eq for TraceEvent

Source§

impl StructuralPartialEq for TraceEvent

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.