Skip to content

Trace

zelos_sdk.trace

TraceSourceCache(name, namespace=None)

A TraceSource wrapper that caches the last value of each field.

Uses a Rust core for cache storage, condition evaluation, and emit decisions. Python layer provides Pythonic attribute navigation.

Example: source = TraceSourceCache("motor_controller") source.add_event("motor_stats", [ TraceEventFieldMetadata("rpm", DataType.Float64), TraceEventFieldMetadata("torque", DataType.Float64, "Nm") ]) source.log("motor_stats", {"rpm": 3500.0, "torque": 42.8}) assert source.motor_stats.rpm.get() == 3500.0

add_event(name, schema, conditions=None, event_type=None)

Register schema (a field list or a class with FIELDS), as TraceSource.add_event. conditions maps field name to its own log condition; unlisted fields take the default.

add_value_table(name, field_name, data)

Register a value table (enum mapping).

Register the event and field with add_event first: a key is typed by the field it labels, so there is nothing to type it against otherwise.

flush()

Flush buffered rows to the router.

get_source()

Not supported — use the cache API directly.

log(name, data)

Log data and update cache. Auto-registers event if not yet registered.

log_at(time_ns, name, data)

Log data at a specific timestamp. Raises ValueError when the emit fails, as TraceSource.log_at does.

log_batch(event_name, data)

Log a pyarrow.RecordBatch or Table, as TraceSource.log_batch. Each column's last non-null value is cached.

log_many(events)

Log (time_ns, name, data) rows in order, as TraceSource.log_many.

set_default_log_condition(condition=_DEFAULT)

Default condition for fields without their own; each field takes a copy. With no argument it is DefaultLogCondition(); None removes it, so those fields log every row.

TraceSourceCacheLastEvent(name, cache, source, conditions=None)

A cached event with attribute access to fields and submessages.

Example: event = source.motor_stats event.rpm.get() # field access event.thermal.temp.get() # submessage access event.log(rpm=3500) # log via event

time_ns property

Wall-clock timestamp of the last log call for this event, in nanoseconds since the Unix epoch. None if the event hasn't been logged yet. Symmetric with 🇵🇾meth:TraceSourceCacheLastField.get.

TraceSourceCacheLastField(name, full_path, data_type, cache, event_name, condition=None, uses_default=False)

A cached field that stores the last logged value.

Example: field = event.rpm field.get() # Get cached value field.name # Full path: "motor_stats.rpm"

get()

Get the cached value.

set(value)

No-op — cache is updated atomically during log() calls in the Rust core. Retained for backward compatibility.