aeat.core.observability._recorder module¶
The single record_event() emit primitive used by every call site.
Routes structured aeat.core.observability._models.RunEvent
records through the standard logging machinery so any handler
attached to the root logger — notably the per-run
aeat.core.observability._sink.JsonlRunSink — picks them up
automatically while a aeat.core.observability.run_context() is
active.
- record_event(kind, *, payload, module=None)[source]¶
Record a single
RunEventagainst the active run context.Context propagation note: the active
run_idis carried viacontextvars.ContextVar. These propagate acrossasyncio.create_task()andasyncio.run()automatically (PEP 567), but NOT across plainthreading.Threadtargets norasyncio.to_thread()/loop.run_in_executorworkers unless the caller wraps the target withcontextvars.copy_context(). A call torecord_event()from a detached thread therefore raisesaeat.core.observability.RunContextMissingError. Callers that need the event recorded in such a thread must either re-enteraeat.core.observability.run_context()inside the worker or copy the context explicitly.- Parameters:
kind (
RunEventKind) – The event kind.payload (
RunEventPayload) – ARunEventPayloadwith exactly one variant set.module (
str|None) – Optional explicit module string; defaults to the caller’s__name__resolved by_caller_module().
- Return type:
- Returns:
The constructed
RunEvent(also forwarded to the JSONL sink via therun_eventlogging extra).- Raises:
RunContextMissingError – If no run context is active on the current contextvar.