channel
etrack.logic.channel
logic/channel: EventChannel — the log that carries the events: reserved keys in, validated record out, fanned out.
The channel is a structlog logger of its own (wrap_logger), so it never touches the host's configuration and the
host's level never drops an event. Its chain: the bound context (run_id, thread_id) merged in → the keys
validated into the channel's model (RunEvent or a project's subclass) → the record published on the bus → a
narrowed line (LogView by default) forwarded to the host's own etrack logger at the phase's level, where the
host's rendering and filtering decide what is printed. Without a bus the channel stands alone: validated, forwarded,
published nowhere — run tracking as log lines, no sink and no worker; hand it a bus to add the sinks. Any code may emit: channel.log.info("run.event", kind=…)
with the reserved keys, or channel.emit(event) with a record already built — the same chain either way.
Like structlog, any other key travels too: a keyword the model does not declare, or a key bound with
structlog.contextvars.bind_contextvars — on this call or around a whole run — lands in the record's attributes, so
every sink sees it (OTLP as span attributes, the HTTP driver in the body) and the forwarded line carries it flat.
Explicit attributes win over a bound key of the same name; a model's own field is never an extra. strict=True
turns that off: a key the model does not declare is refused (ChannelError), and a record already built keeps
only what it was built with.
EventChannel
EventChannel(
bus: BusPort | None = None,
model: type[RunEvent] = RunEvent,
forward: type[EventView] | None = LogView,
*,
strict: bool = False,
)
One emission point per process: validate, publish, forward — then the line is dropped, nothing is rendered here.
log
property
The channel as a logger: log.info("run.event", **reserved_keys) validates, publishes and forwards.
emit
emit(event: RunEvent) -> None
A record already built, through the same chain: published as is, forwarded narrowed.