feat: normalize workspace agent session counts into a child table - #27952
Draft
EhabY wants to merge 1 commit into
Draft
feat: normalize workspace agent session counts into a child table#27952EhabY wants to merge 1 commit into
EhabY wants to merge 1 commit into
Conversation
Replace the fixed session_count_* columns on workspace_agent_stats with a workspace_agent_session_counts child table keyed by app name, so any IDE can report session counts without schema changes. Agent API v2.11 adds a session_counts map to Stats, deprecating the fixed fields.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supersedes #27179 (same branch, squashed and rebased; the original PR had accumulated too much review noise).
Summary
Replaces the four fixed
session_count_*columns onworkspace_agent_statswith a normalized child table,workspace_agent_session_counts, keyed by app name, so any IDE or app can report session counts without schema or code changes.Problem
Session counts were pinned to four hardcoded columns (
vscode,jetbrains,reconnecting_pty,ssh). Every new IDE either mislabeled itself as one of the four or was dropped entirely, and supporting a new name meant a migration plus code changes at every layer.Fix
workspace_agent_session_countstable (PK(workspace_agent_stats_id, app_name),created_atcopied from the parent for windowed pruning, BRIN index), backfilled from the current stats buffer so rollups see no gap during upgrade.session_countsmap toStats, deprecating the fixed fields. Old agents' fixed fields are converted server-side.coderd/idemetadataholds the shared vocabulary:Normalizecanonicalizes client-supplied names at ingestion, andFamilygroups names into bounded families for metric labels.unknownand well-known names are never evicted. The agent applies a matching cap to concurrently active session types.POST /workspaces/{workspace}/usageandcoder ssh --usage-appnow accept arbitrary app names; the allowlist is replaced by ingestion-time normalization.NOTE: The migration backfills the child table and rebuilds an index on
workspace_agent_statsunder lock. The stall is bounded by the stats retention window (~1 day of rows normally, up to 180 days on deployments where the purge never ran).Mixed-version note: a new CLI passing a custom
--usage-appvalue to an older coderd gets a 400, since old servers still validate against the fixed allowlist.🤖 Generated with Claude Code