Implement the flow lifecycle and the `glean.flow_end` event
Categories
(Data Platform and Tools :: Glean: SDK, enhancement, P1)
Tracking
(Not tracked)
People
(Reporter: travis_, Assigned: travis_)
References
(Blocks 5 open bugs)
Details
Attachments
(2 external files)
Open and close flow instances when their boundary events are recorded, and record glean.flow_end when an instance closes. Depends on the tagging bug. Session-end termination, auto_close_timeout, persistence, and the kill switch are separate bugs that build on this one.
Both transitions happen while the triggering event is being recorded. Order within EventMetric::record_sync, after should_record():
- If the event is in a flow's
starts_onand that flow has no active instance, open one: assign the nextflow_seqfrom the session-wide counter and update in-memory state. Nothing is recorded. - Compute the event's session context and
flowsentries, including any instance opened in step 1. Compute these once, before step 4 closes anything, so an exit event is tagged with the instance it closes. - Record the event.
- If the event is in a flow's
ends_onand that flow has an active instance, close it and recordglean.flow_endwithreason: exit. Recording it after the triggering event gives it the highersession.event_seq.
Rules:
- An entry event while the flow is already active does nothing. The instance is not replaced, unlike
session_start(). - An exit event while the flow is not active does nothing.
- No instance opens when no session is active. (The
glean.flows_not_starteddiagnostic is a separate bug.) - Because boundary handling comes after
should_record(), a suppressed or disabled event does not open or close anything.
State: record_sync has &Glean, so the flow manager needs interior mutability. State is a map of active instances plus the session-wide counter, so use a lock.
glean.flow_end:
- Defined in
glean-core/metrics.yamland recorded throughevent_data_store.record()directly, likeglean.session_end, but with an in-session context, notOutOfSession. It never hasflowsentries itself. glean_timestampfromUtc::now().timestamp_millis(). Don't copy the session boundary events, which use the monotonic clock (Bug XXXXXXX).- Combine the
boolreturned byEventDatabase::recordforflow_endwith the triggering event's result, sinceflow_endcan be the event that crosses the buffered-event threshold. - Extras:
flow_name,flow_seq,reason, plusterminating_eventwhenreasonisexitandsession_idwhenreasonisabnormal.
Tests: the worked example in the proposal, including the assertion that settings.opened has no flows entry. Decide here whether a test accessor for live flow state is worth adding, which is one of the open questions on the meta.
Comment 1•18 days ago
|
||
(via GitHub webhook, authenticated as shared-secret)
Comment 2•18 days ago
|
||
(via GitHub webhook, authenticated as shared-secret)
| Assignee | ||
Updated•16 days ago
|
| Assignee | ||
Updated•16 days ago
|
| Assignee | ||
Updated•2 days ago
|
Description
•