fx worktree Telemetry & Metricsfx worktree tracks developer worktree utilization over time to understand average checkout usage, capacity requirements, resource consumption, and the proportion of checkouts built recently vs. not built recently.
To avoid running background daemons while providing continuous statistical precision, fx worktree uses local piecewise-constant time integration combined with a 24-hour periodic snapshot upload.
Local State Accumulation (.fx/metrics/worktree_metrics.json):
fx worktree command executes, the tracker records the current number of total, leased, built recently (built in the last 7 days), and not built recently worktrees.Daily Snapshot Upload:
fx worktree command executed after 24 hours have passed since period_start_ts, the tracker finalizes the 24-hour time-weighted statistics.tools/devshell/lib/metrics_custom_report.sh.Worktree counts change only at discrete events (add, remove, lease, release, build activity). Between events, the count remains constant. Over any interval $[T_0, T_{\text{upload}}]$, the time-weighted average $\bar{N}$ is given by:
$$ \bar{N} = \frac{1}{T_{\text{upload}} - T_0} \int_{T_0}^{T_{\text{upload}}} N(t),dt = \frac{\sum_{i=1}^{k} N_i \cdot \Delta t_i}{T_{\text{upload}} - T_0} $$
Where:
This ensures accurate representation of developer usage across overnight and multi-day periods without active polling.
The state file is stored at .fx/metrics/worktree_metrics.json in the root checkout directory, ensuring that all worktrees in the pool share and update the same state:
{ "period_start_ts": 1756740000.0, "last_change_ts": 1756783200.0, "current_total": 4, "current_leased": 2, "current_built_recently": 3, "current_not_built_recently": 1, "accumulated_total_seconds": 345600.0, "accumulated_leased_seconds": 172800.0, "accumulated_built_recently_seconds": 259200.0, "accumulated_not_built_recently_seconds": 86400.0, "min_total": 2, "max_total": 5, "min_leased": 0, "max_leased": 3, "min_built_recently": 1, "max_built_recently": 4, "min_not_built_recently": 0, "max_not_built_recently": 2 }
period_start_ts: Epoch timestamp (seconds) when the current 24-hour measurement window began.last_change_ts: Epoch timestamp (seconds) when the count was last updated or sampled.current_total: Current total number of physical worktree slots in the pool.current_leased: Current number of worktrees actively leased by a task or developer.current_built_recently: Current number of worktrees that have been built within the last 7 days.current_not_built_recently: Current number of worktrees that are unbuilt or whose last build occurred > 7 days ago (current_total - current_built_recently).accumulated_total_seconds: Integrated time-area product ($\sum N_{\text{total}} \cdot \Delta t$) in second-units.accumulated_leased_seconds: Integrated time-area product ($\sum N_{\text{leased}} \cdot \Delta t$) in second-units.accumulated_built_recently_seconds: Integrated time-area product ($\sum N_{\text{built_recently}} \cdot \Delta t$) in second-units.accumulated_not_built_recently_seconds: Integrated time-area product ($\sum N_{\text{not_built_recently}} \cdot \Delta t$) in second-units.min_* / max_*: Minimum and peak counts observed across each category within the measurement window.When the 24-hour window expires, fx worktree emits a custom event via tools/devshell/lib/metrics_custom_report.sh:
worktreedaily_snapshot{"at":3.0,"mnt":2,"mxt":4,"al":2.0,"mnl":1,"mxl":3,"abr":2.0,"mnbr":1,"mxbr":3,"anbr":1.0,"mnnbr":1,"mxnbr":1}
at, mnt, mxt: Average, min, and max total worktreesal, mnl, mxl: Average, min, and max leased worktreesabr, mnbr, mxbr: Average, min, and max worktrees built recentlyanbr, mnnbr, mxnbr: Average, min, and max worktrees not built recentlyBecause metrics_custom_report.sh forwards the open metrics stream (file descriptor 10) from scripts/fx, the event is automatically joined in the same batch with:
client_id): Persistent anonymized METRICS_UUID.other_uuid): Correlation UUID for ffx, zxdb, and VS Code tools.internal (Googler vs external), is_cog (Cloud Cog vs local workstation), os, arch, and nproc.In compliance with Fuchsia's Analytics Policy:
fx metrics disable or ffx config analytics disable).