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)

Register an event schema.

add_value_table(name, field_name, data)

Register a value table (enum mapping).

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.

set_default_log_condition(condition=None)

Set default log condition. Pass a Python LogCondition or None.

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

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.