feat: attribute session counts by app family - #28337
Merged
Merged
Conversation
This was referenced Aug 19, 2026
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 20, 2026 12:29
2d19a27 to
9d808dd
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 20, 2026 23:41
9d808dd to
0dd464c
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 20, 2026 23:54
0dd464c to
8795832
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 21, 2026 00:04
8795832 to
aa690c5
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 21, 2026 00:15
aa690c5 to
d81e605
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 23, 2026 14:09
d81e605 to
d525a02
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 23, 2026 14:26
d525a02 to
6bc11c5
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 23, 2026 15:04
6bc11c5 to
48f8d80
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 23, 2026 15:33
48f8d80 to
83ef550
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 23, 2026 15:50
83ef550 to
9939793
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
2 times, most recently
from
August 25, 2026 14:15
318f669 to
1575f2f
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
August 25, 2026 15:24
1575f2f to
2b8f6f3
Compare
EhabY
marked this pull request as ready for review
August 25, 2026 15:43
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
2 times, most recently
from
August 25, 2026 20:44
af88378 to
4b55fb5
Compare
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
September 1, 2026 23:22
c60c883 to
c7002b2
Compare
code-asher
reviewed
Sep 4, 2026
code-asher
left a comment
Member
There was a problem hiding this comment.
Broadly looks good to me but what do you think about making the queries return the counts/minutes by app name, and we categorize into families at the point we need to.
That would allow for a richer dashboard for example, since it could get the individual names it could have a way to expand families and see the apps.
More importantly though I feel like it would make the code easier to reason about because we pass and store the same shape everywhere and transform it at the point it is displayed.
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
September 7, 2026 20:11
c7002b2 to
e757a01
Compare
Base automatically changed from
perf/workspace-agent-session-counts-jsonb
to
main
September 7, 2026 20:31
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
2 times, most recently
from
September 8, 2026 16:34
b447184 to
c5bd9ae
Compare
This was referenced Sep 8, 2026
EhabY
removed this pull request from stack #29110
September 9, 2026 14:34
EhabY
added this pull request to stack #29135
September 9, 2026 14:35
code-asher
approved these changes
Sep 9, 2026
Groups app names into families on the read paths, so a session reported under a new name is counted rather than dropped. The codersdk registry maps each known app name to a family and renders the attributed families as one jsonb parameter that every read query and rollup consumes. dbauthz validates the registry structurally, so a missing or renamed family fails loudly instead of silently zeroing a column. The per-agent sum sites decompose session_counts once per row; insights keeps the key presence probe, which is faster there.
EhabY
force-pushed
the
feat/session-count-family-attribution
branch
from
September 10, 2026 11:27
c5bd9ae to
c955a42
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groups app names into families on the read paths, so a session reported under a new name is counted rather than dropped.
codersdkgains the attribution registry:appNameFamiliesmaps each known app name to a family, andSessionCountAppFamiliesJSON()renders the attributed families as a single jsonb parameter. A session reported ascursorcounts as VS Code in template insights, deployment stats, Prometheus, and telemetry.app_familiesparameter instead of four hardcoded name lists. Adding an alias to an existing family is one registry edit that flows everywhere. Adding a family is a registry edit plus one probe per reporting query, since sqlc output columns are static; validation and a pinning test turn a miss into a loud failure instead of a silently zeroed column.{},null, a renamed family, or an extra family fail with the offending key named. It overrides the generated stubs through thescripts/dbgenexternal-method mechanism, covering every production store including rollup transactions.session_countsonce per row, onejsonb_each_textwith a filtered sum per family, instead of a correlated subplan per family. Insights only tests key presence and keeps the?|probe, which is faster there.TestEveryFamilyIsAttributedfails if a family is added with nowhere to report it.TestAttributedAppFamiliesMatchQueriespins the registry to the families the SQL probes.TestSessionCountsAttributeByFamilyandTestUpsertTemplateUsageStatsAttributesSessionCountsByFamilypin the behavior end to end, including the rollup:cursoras VS Code,zedas SSH, an unknown name still marking the user active.Measurements
PG 13, 1M rows, parallelism off, median of 3. The previous per-family correlated subplan against the shipped single-pass fold:
rn = 1analogueThe gating predicates ride inside the lateral as one-time filters, so the decompose is skipped for rows that are not counted, and a per-agent
EXCEPTin both directions over 5000 agents returns zero rows. The insights sites invert this:?|on the alias array measured 613 ms against 1500 ms for decomposing, so presence checks keep?|.Trade-offs
workspace_agent_stats.session_countsdocuments.Depends on #28126. Phase 4 of #27410. Stacked on top: #29134 makes the count queries return per-app counts, and #29109 replaces the fixed per-family minute columns and the per-query probes.
Stack review decisions
Rebased onto main at
3ed8548e78; the attribution patch is unchanged.Update generated by Coder Agents for @EhabY.