Repository navigation
feat: report arbitrary workspace agent session types - #28338
Merged
Merged
Conversation
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 20, 2026 12:39
a9d73b0 to
e77e137
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 20, 2026 23:41
e77e137 to
b47e46c
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 20, 2026 23:54
b47e46c to
c2a30ad
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 21, 2026 00:04
c2a30ad to
7998d2e
Compare
EhabY
added a commit
that referenced
this pull request
Aug 21, 2026
Phase 2 of the Scalable Approach for Adding New IDE Session Types RFC, tracked in #27410. Adds a session_counts map to Stats on the Agent API, so an agent can report a count per app name instead of the four fixed fields, which are now marked deprecated. Bumps the API to v2.11. - coderd normalizes names on ingest, caps distinct entries, and sums the overflow under unknown, so an arbitrary client name cannot blow up cardinality. - Agents predating v2.11 set the fixed fields instead, never both, and the ingest path falls back to them. Nothing sends session_counts yet. The agent starts populating it in #28338.
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 21, 2026 00:15
7998d2e to
13e915b
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
2 times, most recently
from
August 23, 2026 14:26
70d874b to
fa9a7ff
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 23, 2026 15:04
fa9a7ff to
b265c63
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 23, 2026 15:33
b265c63 to
73b679d
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 23, 2026 15:50
73b679d to
7ff8185
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 23, 2026 18:00
7ff8185 to
ea0a9dc
Compare
aslilac
pushed a commit
that referenced
this pull request
Aug 24, 2026
Phase 2 of the Scalable Approach for Adding New IDE Session Types RFC, tracked in #27410. Adds a session_counts map to Stats on the Agent API, so an agent can report a count per app name instead of the four fixed fields, which are now marked deprecated. Bumps the API to v2.11. - coderd normalizes names on ingest, caps distinct entries, and sums the overflow under unknown, so an arbitrary client name cannot blow up cardinality. - Agents predating v2.11 set the fixed fields instead, never both, and the ingest path falls back to them. Nothing sends session_counts yet. The agent starts populating it in #28338.
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
August 25, 2026 14:15
ea0a9dc to
6c8cec9
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 10, 2026 11:27
b1ab129 to
1de03a9
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 10, 2026 11:54
1de03a9 to
adc653e
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 10, 2026 12:07
adc653e to
ce685f3
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 14, 2026 18:10
ce685f3 to
37cb782
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 16, 2026 11:27
37cb782 to
b8fa392
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
2 times, most recently
from
September 16, 2026 12:37
e8b13d0 to
e36be0a
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 16, 2026 12:42
e36be0a to
91a743d
Compare
code-asher
approved these changes
Sep 17, 2026
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 17, 2026 08:55
91a743d to
7b4ea92
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 17, 2026 14:16
7b4ea92 to
f646fdc
Compare
EhabY
force-pushed
the
feat/arbitrary-session-count-producers
branch
from
September 18, 2026 12:58
f646fdc to
8371a0b
Compare
The agent connects on Agent API 2.11 and reports Stats.session_counts from its normalized map, so a new IDE needs no Coder change to show up in usage reporting. coder ssh --usage-app and the workspace usage API pass any app name through, normalized once at the edge. Bound the agent-controlled map in the stats RPC handler, normalizing names before the deterministic cap applies so aliases merge first, and fold the overflow into the unknown app while counting the fold in a Prometheus counter. Discard non-positive raw counts, and treat whitespace-only and control-only app names as absent. Agents at this revision require a coderd that serves v2.11, the same coupling as the v2.10 bump. Older agents keep reporting the deprecated fields, which the batcher still ingests.
The count comes from the capping function rather than a subtraction that undercounts when unknown survives the cut, and folded becomes overflow throughout, metric included. Also tables the session count subtests and drops the benchmark.
Hoist the env prefix in extractAppName, switch getUsageAppName to a plain string since any name is valid, use ContainsFunc for the nameless-app check, and replace a select with testutil.RequireReceive. Correct two comments that described the wrong condition: normalizeUsageAppName returns empty only for whitespace and control characters, not wherever NormalizeAppName reports the unknown family, and the batcher fold test asserts a debug log and a counter rather than a warn throttle.
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.
Enable arbitrary app-name reporting through the agent's
Stats.session_countsmap,coder ssh --usage-app, and the workspace usage API. Reconnecting PTY counts are added to the map without overwriting SSH-reported counts. Unrecognized names retain their identity and are attributed to theunknownfamily.Normalize and merge names before applying the existing deterministic 64-name cap: known apps first, then count, then name. Overflow is summed into
unknown. Non-positive counts cannot cancel valid activity. Control characters are stripped, whitespace/control-only HTTP app names are treated as absent, and SSH session-type extraction requires the exact environment-variable prefix. Overflow entries are counted incoderd_agentstats_session_counts_overflow_total; logs avoid raw payloads and repeated warnings.Compatibility: new agents require a server supporting Agent API v2.11 and do not negotiate down. Older agents remain supported through the deprecated count fields. The usage API's
app_namebecomes a string; SDK types and API documentation are updated. No database migration is added.Completes the producer portion of #27410, now that #29109 has merged. Dynamic API/metrics/UI projections (#27411), per-app insights (#27413), and arbitrary connection-log types (#27412) remain separate. Connection logs still use the existing enum until #27412 lands.
Design decisions and resource bounds
unknown, but temporary processing scales with the input. The agent dRPC transport limits each message to 4 MiB. A local synthetic 200,000-name normalization-and-cap benchmark measured approximately 0.20 s and 25 MB allocated, excluding decoding.Description updated by Coder Agents for @EhabY.
Closes CLIENT-644