Skip to content

Commit 669ffa0

Browse files
committed
Bug 2077138 - Implement the flow lifecycle and the glean.flow_end event
1 parent 828f818 commit 669ffa0

6 files changed

Lines changed: 605 additions & 17 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Fixed a race between initialization and `shutdown()` that could crash with "No database found" when recording the `pre_init` health ping or `glean.error.preinit_tasks_overflow`. Both are now recorded on the dispatcher as the final pre-init task, so shutdown waits for them before closing the database ([bug 2072668](https://bugzilla.mozilla.org/show_bug.cgi?id=2072668))
77
* Accept flow definitions through the configuration and build the event-to-flow index at init. Flows have no effect on recording yet ([bug 2077136](https://bugzilla.mozilla.org/show_bug.cgi?id=2077136))
88
* Events carry a `flows` entry for each active flow instance they belong to, exposed through `testGetValue` as `RecordedEvent.flows` ([bug 2077137](https://bugzilla.mozilla.org/show_bug.cgi?id=2077137))
9+
* Recording a flow's entry event opens an instance and recording its exit event closes it, recording a new `glean.flow_end` event ([bug 2077138](https://bugzilla.mozilla.org/show_bug.cgi?id=2077138))
910

1011
# v71.0.0 (2026-10-22)
1112

‎docs/user/user/collected-metrics/metrics.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ In addition to those built-in metrics, the following metrics are added to the pi
156156

157157
| Name | Type | Description | Data reviews | Extras | Expiration | [Data Sensitivity](https://wiki.mozilla.org/Firefox/Data_Collection) |
158158
| --- | --- | --- | --- | --- | --- | --- |
159+
| glean.flow_end |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Recorded when a flow instance ends. Every instance records exactly one. Recorded in the session that owns the instance, after the instance's last tagged event, but never carries a `flows` entry itself. Its timestamp is when Glean noticed the instance had ended, which is when it actually ended only for `reason: exit`. |[Review 1](TODO data review), [Bug 2077138](https://bugzilla.mozilla.org/show_bug.cgi?id=2077138)|<ul><li>flow_name: The name of the flow, as declared in `flows.yaml`.</li><li>flow_seq: The instance's sequence number within its session. Matches `seq` in the `flows` entries of the instance's tagged events. </li><li>reason: Why the instance ended: - "exit": an event in the flow's `ends_on` was recorded - "timeout": the flow's `auto_close_timeout` elapsed - "session_end": the session ended while the instance was active - "abnormal": the app ended abnormally while the instance was active </li><li>session_id: The session that owned the instance. Only present when `reason` is "abnormal", since that `flow_end` is recorded outside any session. </li><li>terminating_event: The event that closed the instance (`category.name`). Only present when `reason` is "exit". </li></ul>|never |1 |
159160
| glean.session_end |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Recorded when a session ends. Always emitted regardless of session sampling. The `reason` extra key describes why the session ended. |[Review 1](TODO data review), [Bug 2020962](https://bugzilla.mozilla.org/show_bug.cgi?id=2020962)|<ul><li>reason: Why the session ended. When in MANUAL mode, the reason can optionally be set by the application. Possible values set by Glean in AUTO or LIFECYCLE session management modes include: - "inactive": client went to background (LIFECYCLE mode) - "replaced": a new session was started while one was already active - "timeout": AUTO mode inactivity timeout expired - "abnormal": session ended due to app crash/force-close - "abnormal_inactive": session was inactive at time of crash </li><li>session_id: The unique UUID of the ended session.</li><li>session_seq: The session sequence number (monotonically increasing across restarts).</li></ul>|never |1 |
160161
| glean.session_start |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |Recorded when a new session starts. Always emitted regardless of session sampling so analysts can observe all session boundaries and validate sampling rates. |[Review 1](TODO data review), [Bug 2020962](https://bugzilla.mozilla.org/show_bug.cgi?id=2020962)|<ul><li>sampled_in: Whether this session is sampled in (true) or sampled out (false). Events from sampled-out sessions are suppressed; this field lets analysts validate that the observed sampling rate matches the configured rate. </li><li>session_id: The unique UUID of the started session.</li><li>session_seq: The session sequence number (monotonically increasing across restarts).</li><li>session_start_time: Wall-clock timestamp at session start (RFC 3339). Auxiliary only; per-event timestamps remain authoritative for time-based analysis. </li></ul>|never |1 |
161162

‎glean-core/metrics.yaml‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,55 @@ glean:
11811181
- "abnormal_inactive": session was inactive at time of crash
11821182
type: string
11831183

1184+
flow_end:
1185+
type: event
1186+
description: |
1187+
Recorded when a flow instance ends. Every instance records exactly one.
1188+
1189+
Recorded in the session that owns the instance, after the instance's last
1190+
tagged event, but never carries a `flows` entry itself. Its timestamp is
1191+
when Glean noticed the instance had ended, which is when it actually ended
1192+
only for `reason: exit`.
1193+
send_in_pings:
1194+
- events
1195+
bugs:
1196+
- https://bugzilla.mozilla.org/show_bug.cgi?id=2077138
1197+
data_reviews:
1198+
- "TODO data review"
1199+
- https://bugzilla.mozilla.org/show_bug.cgi?id=2077138
1200+
data_sensitivity:
1201+
- technical
1202+
notification_emails:
1203+
- glean-team@mozilla.com
1204+
expires: never
1205+
extra_keys:
1206+
flow_name:
1207+
description: The name of the flow, as declared in `flows.yaml`.
1208+
type: string
1209+
flow_seq:
1210+
description: |
1211+
The instance's sequence number within its session. Matches `seq` in
1212+
the `flows` entries of the instance's tagged events.
1213+
type: quantity
1214+
reason:
1215+
description: |
1216+
Why the instance ended:
1217+
- "exit": an event in the flow's `ends_on` was recorded
1218+
- "timeout": the flow's `auto_close_timeout` elapsed
1219+
- "session_end": the session ended while the instance was active
1220+
- "abnormal": the app ended abnormally while the instance was active
1221+
type: string
1222+
terminating_event:
1223+
description: |
1224+
The event that closed the instance (`category.name`). Only present
1225+
when `reason` is "exit".
1226+
type: string
1227+
session_id:
1228+
description: |
1229+
The session that owned the instance. Only present when `reason` is
1230+
"abnormal", since that `flow_end` is recorded outside any session.
1231+
type: string
1232+
11841233
sessions_seen:
11851234
type: counter
11861235
description: |

0 commit comments

Comments
 (0)