pynenc.trigger.monitoring¶
Monitoring DTOs for the trigger component.
These dataclasses are the durable monitoring contract that trigger backends
expose to any visibility / observability consumer. They follow the same
shape as InvocationHistory and other pynenc DTOs: backend-neutral, JSON
round-trippable, UTC-aware timestamps, and no dependency on any specific UI.
Module contents:
- class:
EventRecord: durable record of one emitted event.
- class:
EventMarker: lightweight projection used by timeline overlays.
- class:
EventMarkerPage: paginated marker projection with truncation flag.
- class:
TriggerRunRecord: durable record of one trigger run.
- class:
TriggerRunParticipant: per-condition row attached to a trigger run preserving which condition each event or source invocation satisfied.
Design notes:
EventRecord.triggered_invocation_idsis rehydrated on read from the per-event invocation index rather than rewritten on the hot path.- class:
TriggerRunParticipantstores only reference ids and lightweight labels. Detail views re-fetch the liveTriggerCondition/ context through :meth:BaseTrigger.get_conditionand the event / state-backend lookups when they need full payloads.
Module Contents¶
Classes¶
Durable record of an emitted event. |
|
Lightweight projection of an event used by the timeline overlay. |
|
Paginated event-marker projection with explicit truncation metadata. |
|
Per-condition row attached to a :class: |
|
Durable record of a single trigger run. |
Functions¶
Return a UTC timezone-aware |
|
Parse an ISO timestamp string, defaulting to “now” when missing. |
|
Parse an ISO timestamp string into UTC, returning |
|
Return |
API¶
- pynenc.trigger.monitoring._now_utc() datetime.datetime[source]¶
Return a UTC timezone-aware
datetimefordefault_factoryusage.
- class pynenc.trigger.monitoring.EventRecord[source]¶
Durable record of an emitted event.
Created by :meth:
pynenc.trigger.base_trigger.BaseTrigger.emit_eventregardless of whether any condition matched. The first write captures the payload; a single follow-up write records matched/valid condition IDs when at least one condition accepts the event.triggered_invocation_idsis populated by the backend on read from a dedicated event->invocation index. The hot path does not rewrite the event JSON to append invocation IDs.- timestamp: datetime.datetime¶
‘field(…)’
- to_json(app: pynenc.app.Pynenc) str[source]¶
Serialize to JSON, routing payload values through the data store.
- _to_dict(app: pynenc.app.Pynenc) dict[str, Any][source]¶
Return a JSON-ready dict using
app.client_data_storefor payload.
- classmethod from_json(json_str: str, app: pynenc.app.Pynenc) pynenc.trigger.monitoring.EventRecord[source]¶
Rebuild an :class:
EventRecordfrom its JSON representation.
- classmethod _from_dict(data: dict[str, Any], app: pynenc.app.Pynenc) pynenc.trigger.monitoring.EventRecord[source]¶
- class pynenc.trigger.monitoring.EventMarker[source]¶
Lightweight projection of an event used by the timeline overlay.
Backends populate this directly from indexed columns without deserializing the full event payload. The marker is intentionally narrow so a busy timeline window can load many markers cheaply.
- timestamp: datetime.datetime¶
None
- class pynenc.trigger.monitoring.EventMarkerPage[source]¶
Paginated event-marker projection with explicit truncation metadata.
truncatedisTruewhen the backend stopped atlimitand more markers exist for the requested window. Pynmon uses this to surface a visible “showing N of more” hint instead of silently dropping markers.- markers: list[pynenc.trigger.monitoring.EventMarker]¶
None
- class pynenc.trigger.monitoring.TriggerRunParticipant[source]¶
Per-condition row attached to a :class:
TriggerRunRecord.Preserves the mapping between a valid condition and the event or source invocation that satisfied it. Composite (AND) triggers need this to answer “which condition did each participant satisfy?”.
Exactly one of
event_id/source_invocation_idis populated for event/status/result/exception conditions.CronContextand other contexts without a discrete source populate neither.context_timestampandcontext_summaryare lightweight labels so the timeline overlay and tooltip rows can anchor and describe a participant without re-fetching the source record. Full condition and context payloads are re-fetched on demand from the trigger registry and the event / state-backend lookups when a detail panel is opened.- context_timestamp: datetime.datetime | None¶
None
- class pynenc.trigger.monitoring.TriggerRunRecord[source]¶
Durable record of a single trigger run.
Captures the participants that satisfied the trigger and the resulting invocation.
participantspreserves the per-condition mapping that the parallelevent_ids/source_invocation_idslists lose. The parallel lists are kept for backward compatibility and as a flat index for backends that do not need the per-condition mapping.- claimed_at: datetime.datetime | None¶
None
- executed_at: datetime.datetime | None¶
None
- participants: list[pynenc.trigger.monitoring.TriggerRunParticipant]¶
‘field(…)’
- classmethod from_json(json_str: str) pynenc.trigger.monitoring.TriggerRunRecord[source]¶
Rebuild a :class:
TriggerRunRecordfrom its JSON representation.
- pynenc.trigger.monitoring._parse_timestamp(value: Any) datetime.datetime[source]¶
Parse an ISO timestamp string, defaulting to “now” when missing.
- pynenc.trigger.monitoring._parse_timestamp_optional(value: Any) datetime.datetime | None[source]¶
Parse an ISO timestamp string into UTC, returning
Nonewhen missing.