Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: normalize workspace agent session metadata - #28124

Merged
EhabY merged 4 commits into
mainfrom
refactor/normalize-agent-session-metadata
Aug 20, 2026
Merged

refactor: normalize workspace agent session metadata#28124
EhabY merged 4 commits into
mainfrom
refactor/normalize-agent-session-metadata

Conversation

@EhabY

@EhabY EhabY commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

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.

  • Adds codersdk/appname.go: NormalizeAppName for storage and lookup, and AppFamilyName for the places that need a bounded value, such as a Prometheus label or the Connection_Type enum.
  • agentssh.Server keeps session counters in a map keyed by normalized name instead of three fixed atomics, dropping entries at zero.
  • Drops MagicSessionType. Sessions carry plain app names, and unrecognized ones flow through as themselves rather than collapsing to unknown.

Wire behavior is unchanged: the agent still reports the four session_count_* fields over Agent API 2.10.

Stack

  1. this PR: normalize agent session metadata
  2. feat: add workspace agent session count protocol #28125: add the Stats.session_counts protocol field
  3. perf: store workspace agent session counts as JSONB #28126: store session counts as JSONB (the only migration in the stack)
  4. feat: attribute session counts by app family #28337: attribute session counts by app family
  5. feat: report arbitrary workspace agent session types #28338: report arbitrary session types

@EhabY
EhabY force-pushed the refactor/normalize-agent-session-metadata branch from 099eee9 to a75121e Compare August 13, 2026 16:29
@EhabY
EhabY requested a review from code-asher August 13, 2026 17:08
@EhabY
EhabY marked this pull request as ready for review August 13, 2026 17:08
@EhabY
EhabY force-pushed the refactor/normalize-agent-session-metadata branch 3 times, most recently from 124a7d1 to ac5af73 Compare August 19, 2026 23:25
@EhabY
EhabY force-pushed the refactor/normalize-agent-session-metadata branch from ac5af73 to 341e227 Compare August 19, 2026 23:43

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A beautiful first step!

Comment thread coderd/idemetadata/idemetadata.go Outdated
Comment thread codersdk/appname.go Outdated
Comment thread coderd/idemetadata/idemetadata.go Outdated
Comment thread coderd/idemetadata/idemetadata.go Outdated
Comment thread coderd/idemetadata/idemetadata.go Outdated
Comment thread coderd/idemetadata/idemetadata_test.go Outdated
Comment thread agent/agentssh/agentssh.go Outdated
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.
@EhabY
EhabY requested a review from code-asher August 20, 2026 11:31

@code-asher code-asher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nits, looks good!

Comment thread agent/agentssh/agentssh.go Outdated
Comment thread agent/agentssh/agentssh.go Outdated
Comment thread agent/agentssh/agentssh.go Outdated
Comment thread codersdk/appname.go Outdated
Comment thread codersdk/appname.go
EhabY added 2 commits August 21, 2026 00:25
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.
@EhabY
EhabY merged commit c767cc5 into main Aug 20, 2026
47 of 50 checks passed
@EhabY
EhabY deleted the refactor/normalize-agent-session-metadata branch August 20, 2026 23:22
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants