Repository navigation
feat: expose per-app session counts - #29351
Conversation
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. |
a5de245 to
9abc1e5
Compare
9abc1e5 to
72f01ce
Compare
72f01ce to
01c9c50
Compare
01c9c50 to
f1e6046
Compare
f1e6046 to
4cc62ca
Compare
fb5193f to
ddc428f
Compare
ddc428f to
91b570e
Compare
91b570e to
eddc4ac
Compare
eddc4ac to
fdf6f82
Compare
c9ba7be to
acfe371
Compare
acfe371 to
57faaf8
Compare
57faaf8 to
e8b3806
Compare
| return nil, err | ||
| } | ||
|
|
||
| sessionCountLabels := append(slices.Clone(aggregateByLabels), "app_name", "family") |
There was a problem hiding this comment.
Just an IMO thing, but I feel like we should only emit the app name. Grouping is something that should be done at query/display time when necessary, especially since we would not be able to change the metrics retroactively to account for new families or apps, but a query change can.
That gives us a smooth continuation from vscode to still vscode, as well, rather than having vscode and then vscode_vscode.
But I am not super familiar with Prometheus so there could be some bad assumptions I am making.
There was a problem hiding this comment.
I'd like to keep family. It comes straight from app_name, so it adds no series. Prometheus also can't look up our app list, so without the label, totaling by family means a regex per app. app_name is still there if you want to regroup differently at query time.
On continuity, VS Code shows up as {app_name="vscode", family="vscode"}, so there's no vscode_vscode.
There was a problem hiding this comment.
Oh right yeah that makes sense, I just meant the testuser:workspace-1:example:coderd_agentstats_session_count_vscode_vscode
Fair though that users can group them and just ignore the family label, although that requires operators to be aware the categorization is best-effort and possibly wrong.
Just feels sketchy to me to emit data that is basically guaranteed to be wrong eventually (as long as we keep adding support for new VS Code forks and other editors, which happens at a faster pace than people update Coder to get a new family list).
Part of the problem for me is I am not sure how people actually use this data, so it is hard to know if the design for it is correct. If they are just displaying some total counts per family on a dashboard somewhere, probably not a big deal if some of the numbers are incorrectly in one family versus another. If the numbers are used to justify something about one family of editors versus another, then maybe it does become more important.
If the family is important to emit, maybe this is an indication that the client should report its own family instead of coderd.
There was a problem hiding this comment.
But, I am probably overthinking it lol
There was a problem hiding this comment.
To me it's because the old way is basically the family. Family here essentially means "program", VS Code has one codebase, jetbrains is the same, Zed can potentially be a family if we decide to go there.
Would another name make more sense for this?
There was a problem hiding this comment.
My take on it is that it was meant to be more just a loose grouping like "the jetbrains editors", "vs code", "everything else that uses ssh") than strictly "these are based off the same codebase". Just to sort of help admins get a big-picture view of how the product was being used. (I suspect the fragmentation of VS Code was not considered when implemented.)
The naming itself is not really a problem though imo, it is more that previously, adding a new vs code editor for example would go into the right group "vscode" without a coderd update since it would send "vscode" as its name. Now, a coderd update is separately required which means the data emitted prior to upgrading will be incorrectly grouped.
Unlike for example the stats endpoint, where once coderd updates it would start emitting the correct family for older entries (since it is runtime and not in the database).
So the issue is more that classification happens during storage instead of run/query time. Having clients emit their own family/category/type would sort of work around it.
But idk if this is a real issue in practice, just stuck out to me is all. Possibly no one cares at all lol
There was a problem hiding this comment.
I had a brain fart from switching contexts but actually the family is derived at runtime literally everywhere else so I'll look for a way
There was a problem hiding this comment.
This now achieves this but it sadly makes the PromQL query slower: a324817
This happens in Prometheus and it's only the query we suggest in the MD file so admins still have to use it.
5ee9c3f to
b2004e9
Compare
b2004e9 to
f9a89c3
Compare
Expose normalized app identifiers, counts, and registry presentation metadata in deployment stats, Prometheus, and telemetry. Retain deprecated family fields and gauges for compatibility and bound per-report names with an explicit overflow bucket. Group deployment banner connections by family with alphabetical app tooltips, a Visual Studio Code label, and distinct loading and empty states. Generated with Coder Agents.
Keep app-keyed session counts separate from current registry metadata. Document pinned metadata joins with unknown fallback and explicit replica conflicts, with concise guidance and a collapsible multi-deployment query. Add separation between connection icons and the banner's timestamp section. Generated with Coder Agents.
a324817 to
9334e82
Compare
Expose per-app session counts in deployment stats, Prometheus, telemetry, and the deployment banner.
SessionCountDeploymentStats.Appsretains each reported app's normalized identifier with its count, current family, display name, and optional bundled icon. The server-owned registry supplies attribution and presentation; unrecognized apps keep their identifiers, and reported names never become image URLs. The banner retains family totals, adds an Other slot, and lists individual apps alphabetically on hover or focus.Prometheus exports app-keyed observations in
coderd_agentstats_session_count, without afamilylabel. A separatecoderd_agentstats_app_info{app_name,family}gauge exposes the current registry. The documented queries enrich retained app history with current metadata and preserve unmatched counts asunknown, without rewriting historical samples. Metadata is initialized once when the collector starts and served on every scrape. The join runs in the querying Prometheus server, not in thecoderdAPI or background SQL collection path.Each statistics report retains up to 64 distinct app names and sums excess names into
app_name="overflow". Blank names and client-supplied reservedoverflownames normalize tounknown. Collections with reports replace session series; empty collections retain the previous snapshot. The four deprecated API fields and four family-specific gauges remain for compatibility; removal is tracked in https://linear.app/codercom/issue/CLIENT-980.Refs https://linear.app/codercom/issue/DEVEX-641
Before merge
WorkspaceAgentStat.SessionCountssends normalized app names off the deployment, including custom names supplied by templates.docs/admin/setup/telemetry.mddiscloses this, but the same page states Coder does not collect parameters or environment variables, so this needs an explicit decision. Names are truncated to 64 runes and reports retain up to 64 distinct names plus overflow. Receiver schema and ingestion sign-off are also required.Implementation decisions and performance evidence
The branch has two reviewable commits:
bc5a57219bcontains the per-app feature and loading accessibility fix;9334e827bfcontains query-time family grouping, concise Prometheus guidance, and spacing after the connection icons.Agreed implementation
app_nameand existing identity labels on count observations; export family metadata separately for every registered app, including apps without active sessions.@ end()is not current metadata for an old graph.unlessfallback so missing mappings do not silently drop sessions. Missing metadata, including scrape failures or staleness, appears asunknown.Performance and execution path
A synthetic Prometheus 3.11.2 benchmark used approximately 100.8 million samples, 15-second sampling, and a 2-CPU/4-GiB limit. For 10,000 series over 24 hours at one-minute graph steps, the current-metadata fallback query took approximately 2.96 seconds median versus 1.48 seconds for direct family grouping. These are graph-query timings, not
coderdrequest timings or production capacity estimates.The fallback evaluates counts twice. A separate controlled comparison at 0%, 1%, 2%, and 5% unknowns showed essentially unchanged fallback cost. Stable low-effort rewrites did not materially improve it. We accept this cost initially while retaining app-keyed observations so queries can be optimized later; optional app-keyed recording rules would require configuration and resolution/dimension decisions.
The registry currently contains 18 entries. Their metadata gauges are populated once per collector initialization, then scraped routinely. This follow-up adds no SQL query or synchronous dependency to Coder API requests. Prometheus queries can still compete for host resources if Prometheus and Coder share a host; net scrape-latency changes were not benchmarked.
Completed validation for the follow-up
go test -race ./coderd/prometheusmetrics/... -count=1Earlier review follow-ups
The banner uses family slots rather than the four busiest apps, with alphabetical app rows, restored SSH and Web Terminal icons, and corrected icon padding. The overflow bucket is separate from blank-name
unknown, and the overflow counter help text matches. The broken-icon fallback was removed; app names remain visible beside their icons. Loading connection labels and tooltips no longer report zero sessions. Padding before the timestamp section preserves separation from the last connection icon; it adds 32px to the banner's minimum content width.Updated by Coder Agents on behalf of @EhabY. Earlier implementation assistance: Claude Code.