feat: return per-app session counts from workspace agent stats queries - #29134
Merged
Conversation
EhabY
added this pull request to stack #29135
September 9, 2026 14:35
This was referenced Sep 9, 2026
EhabY
marked this pull request as ready for review
September 9, 2026 18:13
EhabY
force-pushed
the
feat/session-count-generic-queries
branch
from
September 10, 2026 11:27
a5fda49 to
6a5169f
Compare
Base automatically changed from
feat/session-count-family-attribution
to
main
September 10, 2026 11:54
The six raw session count aggregates return a session_counts jsonb object of app name to sessions instead of one fixed column per family, so a session reported under an app name this version does not know about is counted rather than dropped. Callers fold the object into families with codersdk.SessionCountsByFamily. Summing per app name in a separate subquery keeps the byte, latency, and connection aggregates free of the decomposed rows, and joining the per-agent sums back keeps an agent whose latest row reports no sessions. With no family named in SQL, the six queries no longer take the app family registry, so dbauthz stops validating it for them.
Preserve empty latest reports, labels, and byte and latency aggregates without decomposing and reaggregating a single session-count row. Generated by Coder Agents for @EhabY.
EhabY
force-pushed
the
feat/session-count-generic-queries
branch
from
September 10, 2026 11:54
6a5169f to
6b9e4fd
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.
Make the six raw session-count queries in
workspaceagentstats.sqlreturn onesession_countsJSONB keyed by app name, and fold it into the existing per-family fields in Go withcodersdk.SessionCountsByFamily.Previously each query probed one hardcoded name list per family, so a new family needed a probe in six queries and a matching output column. Now the queries know nothing about families: counts are additive per app, the fold happens once in Go, and unknown names are counted under
unknownrather than dropped. Deployment stats, Prometheus, and telemetry keep their existing fields and values. The registry parameter and its dbauthz validation go away for these six queries; they return to plain forwarding, as onmain.The two latest-row queries select session counts directly from the single latest eligible row, without decomposing and reaggregating its JSONB. Byte and latency aggregates stay in their own subqueries so expanding
session_countsnever multiplies them, and an agent whose latest row reports no sessions keeps its row with zero counts; both are pinned by tests.Stacked on #28337. #29109 follows with the
template_usage_statsstorage change. Prepares #27411.Description generated by Coder Agents for @EhabY.
Stack review decisions
Preserve the latest-row projection and output layout; remove only the redundant single-row session-map aggregation.