Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: return per-app session counts from workspace agent stats queries - #29134

Merged
EhabY merged 2 commits into
mainfrom
feat/session-count-generic-queries
Sep 10, 2026
Merged

feat: return per-app session counts from workspace agent stats queries#29134
EhabY merged 2 commits into
mainfrom
feat/session-count-generic-queries

Conversation

@EhabY

@EhabY EhabY commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Make the six raw session-count queries in workspaceagentstats.sql return one session_counts JSONB keyed by app name, and fold it into the existing per-family fields in Go with codersdk.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 unknown rather 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 on main.

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_counts never 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_stats storage 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.

@EhabY
EhabY added this pull request to stack #29135 September 9, 2026 14:35
@EhabY
EhabY marked this pull request as ready for review September 9, 2026 18:13

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@EhabY
EhabY force-pushed the feat/session-count-generic-queries branch from a5fda49 to 6a5169f Compare September 10, 2026 11:27
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
EhabY force-pushed the feat/session-count-generic-queries branch from 6a5169f to 6b9e4fd Compare September 10, 2026 11:54
@EhabY
EhabY merged commit 0aae890 into main Sep 10, 2026
24 checks passed
@EhabY
EhabY deleted the feat/session-count-generic-queries branch September 10, 2026 12:07
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants