Repository navigation
fix: deduplicate template insights family metrics - #30497
Merged
Merged
Conversation
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. |
This was referenced Oct 8, 2026
EhabY
force-pushed
the
fix/insights-family-metrics
branch
4 times, most recently
from
October 8, 2026 16:25
7053de1 to
91d62e9
Compare
2 tasks
EhabY
marked this pull request as ready for review
October 8, 2026 16:29
EhabY
force-pushed
the
fix/insights-family-metrics
branch
2 times, most recently
from
October 8, 2026 16:36
09e47eb to
e5ed18e
Compare
EhabY
force-pushed
the
fix/insights-family-metrics
branch
from
October 12, 2026 13:20
e5ed18e to
b77bd9e
Compare
coderd_insights_applications_usage_seconds summed each family's per-app minutes, so apps of one family open in the same minute counted that minute more than once. GetTemplateInsightsByTemplate now takes the registry's app-to-family mapping as jsonb, groups the raw agent stats by family, and counts each minute once per user and family. The metric keeps its existing built-in series and labels. Also pins how the 000596 rollback approximates family minutes from per-app rows.
EhabY
force-pushed
the
fix/insights-family-metrics
branch
from
October 12, 2026 13:58
b77bd9e to
e954704
Compare
ssncferreira
approved these changes
Oct 12, 2026
ssncferreira
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, just a few notes 👍
- Rename the family_usage CTE to app_family_usage and familySeries to appFamilySeries. - Drop the TemplateBuiltinAppDisplayName* constants; the insights handler uses AppFamilyName.DisplayName(), which returns the same strings. - Move the prometheus.md section into the metric's HELP text. - Note each app's family in the migration 000596 rollback test cases.
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.
Summary
coderd_insights_applications_usage_secondssummed each family's per-app minutes. Because of that, a user with VS Code and Cursor open in the same minute was reported as two VS Code minutes. This PR counts each user-minute once per template and app family. It reads the raw agent statistics, because the rollup keeps minutes per app and cannot tell overlapping apps apart.This implements the metrics portion of Completing Scalable IDE Session Tracking RFC, separately from the per-app HTTP API and UI.
Changes
GetTemplateInsightsByTemplatetakesapp_families, a jsonb app→family map built fromcodersdk.SessionCountAppFamilies(). It groups the raw stats by family and counts distinct minutes per user and family. App names not in the map count asunknown.AppFamilyName.DisplayName(), backed by one family display-name table, and removes theTemplateBuiltinAppDisplayName*constants it duplicated. Nothing outside the template insights handler used them. Existing labels are kept; #29906 renames the VS Code family.GetTemplateInsightsand the per-app HTTP/UI path behave the same; #29796 handles them. The handler's built-in display names now come fromDisplayName(), which returns the same strings. No migration and no storage changes.Line breakdown
codersdk)Follow-up
This PR stays non-breaking: the metric keeps its four built-in series and labels. SFTP, port forwarding, and unrecognized apps stay unreported here, as on
main. #29906 moves all families, those included, to their own metric,coderd_insights_session_families_usage_seconds, labeled by family key. Per-app usage is in the HTTP API and UI with #29796; a per-app Prometheus metric is tracked in #29940.Performance
The query runs once per collector tick, every five minutes. The benchmark below ran on Postgres 17 with default
work_memand 6 hours of synthetic agent stats, with agents reporting every 30s and a 5-minute window. Times are the median of 7 runs.main(per-app)Deduplicating by family costs at most about 4%. An earlier version of this PR passed the mapping as two parallel arrays; it was 12 to 18% slower and spilled to disk at 5,000 agents. At 20,000 agents both
mainand this PR spill about 8 MB per worker in the existing join on template and user.Operational impact
Family values can drop wherever the old per-app sum double-counted overlapping apps. The metrics window defaults to five minutes. Raw agent stats are kept for roughly a day behind the rollup, so a custom window longer than that would undercount session families.
Stack
Targets
main. Review and land in order: #30497 → #29796 → #29906. The connection-log stack (#30466 → #30467) is independent.Generated with Coder Agents on behalf of @EhabY.