Repository navigation
refactor: share the session app fold rule and method derivation - #31028
Merged
Merged
Conversation
This was referenced Oct 19, 2026
EhabY
force-pushed
the
feat/session-app-method
branch
5 times, most recently
from
October 20, 2026 16:20
fb63c2b to
e637696
Compare
Contributor
Docs previewCheck off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. |
EhabY
marked this pull request as ready for review
October 26, 2026 18:23
EhabY
force-pushed
the
feat/session-app-method
branch
2 times, most recently
from
October 26, 2026 19:29
d4effdf to
1935137
Compare
EhabY
force-pushed
the
feat/session-app-method
branch
from
October 26, 2026 19:57
e7d552f to
98c30b9
Compare
code-asher
approved these changes
Oct 26, 2026
Store the connection method of each session app in template_usage_stats_session_apps and nest workspace_agent_stats.session_counts by method. Coderd derives the method from the app name at ingest, so the agent protocol, CLI, and API are unchanged. Migration 000630 blocks writes to workspace_agent_stats, converts the rows the rollup and operational readers still read, and adds a NOT VALID check that rejects flat session counts, so a coderd still on the previous release cannot write rows the new readers fail on. It also adds session_count_apps, whose row estimate keeps the rollup's plan from degrading on large tables. Insights group and fold "Other apps" per method, with the same rule and order as ingest (codersdk.FoldUnregisteredSessionApps). Operational readers return the stored objects and coderd sums them per app, so metricscache, telemetry, and Prometheus are unchanged. Closes #31012
Migration 000634 now adds the workspace_agent_stats CHECK before it alters template_usage_stats_session_apps, so it takes its locks in the same order as UpsertTemplateUsageStats and cannot deadlock with a rollup on a replica that still runs the previous release. The CHECK also rejects keys that are not session methods, dbgen emits constants for CHECKs added with ALTER TABLE, and a test checks the SQL fold across methods against codersdk.FoldUnregisteredSessionApps.
Every reporter's app name implies its method, so storing the method adds no information until a reporter sends one (CLIENT-1053), and that change can store it in the child table of CLIENT-1062 with a single migration. This drops migration 000634, the nested session_counts, and the method column, and keeps the shared fold rule: codersdk.SessionAppMethod and an app-keyed codersdk.FoldUnregisteredSessionApps, used by ingest and mirrored by GetTemplateInsights.
EhabY
force-pushed
the
feat/session-app-method
branch
from
October 26, 2026 20:41
98c30b9 to
7123b57
Compare
EhabY
enabled stacked auto-merge (squash)
October 26, 2026 20:46
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.
Share one fold rule and one method rule for session apps, so ingest, the template insights API, and the Prometheus collector in #29906 agree.
codersdk.SessionAppMethodderives a session app's connection method from its name:reconnecting_ptyandport_forwardingkeep their own method, every other name isssh. It moves here fromcoderd/insights.goso feat!: label the VS Code family and report built-in app usage per app #29906 can label series with it. Every current reporter's app name implies its method, so the method is not stored.codersdk.FoldUnregisteredSessionAppsis the fold rule thatGetTemplateInsightsalready applies in SQL: registered apps,unknown, andoverflowkeep their entries, the 64 busiest other apps keep theirs, ties break by app name in byte order, and the rest add up underoverflow.capSessionCounts. Before, a report kept 64 names in total, ranking registered names first; now registered names andunknownnever fold, and at most 64 unregistered names keep theirs.No schema, API, or protocol change.
Refs #31012, CLIENT-1052
Size
Decision log
session_counts({method: {app: count}}), amethodcolumn intemplate_usage_stats_session_apps, and migration 000634, which lockedworkspace_agent_statsand made replicas still on the previous release fail their stats writes. The last commit reverts that. A stored method adds no information while every app name implies its method. The source that first sends a method (port-forward counting, CLIENT-1053) can store it in the child table that CLIENT-1062 proposes forsession_counts, so the data migrates once instead of twice. The branch keeps both commits for the history.GetTemplateInsightsalready ranked by usage, then by app name withCOLLATE "C", and exempted registered apps,unknown, andoverflow. The Go helper matches it, so the API, ingest, and the metric fold the same apps.