refactor: normalize workspace agent session metadata - #28124
Merged
Conversation
EhabY
force-pushed
the
refactor/normalize-agent-session-metadata
branch
from
August 13, 2026 16:29
099eee9 to
a75121e
Compare
EhabY
marked this pull request as ready for review
August 13, 2026 17:08
EhabY
force-pushed
the
refactor/normalize-agent-session-metadata
branch
3 times, most recently
from
August 19, 2026 23:25
124a7d1 to
ac5af73
Compare
4 tasks
EhabY
force-pushed
the
refactor/normalize-agent-session-metadata
branch
from
August 19, 2026 23:43
ac5af73 to
341e227
Compare
code-asher
reviewed
Aug 20, 2026
Address review on #28124: the app name vocabulary now lives next to the UsageAppName enum it must not drift from, so agent, coderd, and cli share one declaration. - Move coderd/idemetadata to codersdk/appname.go as NormalizeAppName and AppNameFamily. - Fold canonicalKey into NormalizeAppName so there is one notion of a normalized name, and normalize before family lookup. - Drop MagicSessionType and its constants; sessions carry plain app names. - Drop AppNameZed, which is a leaf name rather than a family.
code-asher
approved these changes
Aug 20, 2026
code-asher
left a comment
Member
There was a problem hiding this comment.
Just some nits, looks good!
Address review on #28124. - Rename the enum-shaped AppName* constants to AppFamily* behind a new AppFamilyName type, so a family is distinct from a raw app name. - Rename magicType to appName across agentssh and agent, including extractAppName and appNameMetricLabel. - Unexport MaxAppNameLength and drop the unused MaxSessionCountEntries. The magic_type metric label and MagicSessionTypeEnvironmentVariable keep their names: renaming them breaks dashboards and the wire contract.
…eEnvironmentVariable The Go identifier is package-local vocabulary. The env var value stays CODER_SSH_SESSION_TYPE, so no client changes.
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.
Phase 1 of the Scalable Approach for Adding New IDE Session Types RFC, tracked in #27410.
Gives agent session accounting one canonical vocabulary for app names, so later work can report a count per app without the agent and the server disagreeing about what an app is called.
codersdk/appname.go:NormalizeAppNamefor storage and lookup, andAppFamilyNamefor the places that need a bounded value, such as a Prometheus label or theConnection_Typeenum.agentssh.Serverkeeps session counters in a map keyed by normalized name instead of three fixed atomics, dropping entries at zero.MagicSessionType. Sessions carry plain app names, and unrecognized ones flow through as themselves rather than collapsing tounknown.Wire behavior is unchanged: the agent still reports the four
session_count_*fields over Agent API 2.10.Stack
Stats.session_countsprotocol field