Skip to content

chore: remove workspace-usage experiment - #30206

Closed
f0ssel wants to merge 2 commits into
mainfrom
remove-workspace-usage-experiment
Closed

f0ssel wants to merge 2 commits into
mainfrom
remove-workspace-usage-experiment

Conversation

@f0ssel

@f0ssel f0ssel commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Removes the workspace-usage experiment and the behavior behind it. Every code path now behaves as it did with the experiment off, which is the default. The public SDK and API surface is deprecated instead of removed.

What the experiment did

With workspace-usage enabled, clients sent {agent_id, app_name} to POST /api/v2/workspaces/{id}/usage. The server recorded a synthetic agent stat for that request and set usage=true on it. At the same time, the server dropped session counts reported by the agent. Metrics cache, Prometheus, and telemetry then read from separate *Usage* queries that filtered on the usage column.

Changes

  • SDK/API: ExperimentWorkspaceUsage, PostWorkspaceUsageRequest, UsageAppName*, PostWorkspaceUsageWithBody, and UpdateWorkspaceUsageWithBodyContext stay but are marked Deprecated. The body variants forward to the no-body PostWorkspaceUsage / UpdateWorkspaceUsageContext, which are no longer marked deprecated. workspace-usage is dropped from ExperimentsKnown, so setting it logs the existing "ignoring unknown experiment" warning.
  • Server: POST /workspaces/{id}/usage stays, and so does its optional body in Swagger, now documented as ignored. It does what it did with the experiment off: bump last_used_at and return 204. Agent session counts are no longer cleared.
  • Stats plumbing: removes the usage bool parameter from Reporter.ReportAgentStats, Batcher.Add, metricscache.New, and prometheusmetrics.AgentStats. Removes the now-unused agentapi Experiments option and the HasSessionCounts/ClearSessionCounts helpers.
  • Database: removes GetDeploymentWorkspaceAgentUsageStats, GetWorkspaceAgentUsageStats, and GetWorkspaceAgentUsageStatsAndLabels. Migration 000606 drops workspace_agent_stats.usage.
  • CLI: ssh, vscodessh, and exp rpty send heartbeats without a body. The hidden --usage-app flag is kept because the VS Code extension passes it. disable still turns off heartbeats, and any other value is ignored.
  • Frontend: workspaceUsage no longer takes usageApp and posts without a body.

Compatibility notes

  • Deployments that still set CODER_EXPERIMENTS=workspace-usage will get the usual unknown-experiment handling.
  • Rows written with usage=true before the upgrade become ordinary agent stats. These rows age out with the normal stats retention window.
Implementation plan / decision log
  • Spec: treat experiment-off behavior as the source of truth everywhere. Keep TrackUsage / last_used_at, agent-reported session counts, and insights unchanged.
  • DB column: drop it with a new migration rather than leaving a dead column. Historical migrations are untouched. The down migration restores the column with its default, but it cannot restore the old values.
  • HTTP compatibility: keep the route, its auth, and the 204 response. Tolerate legacy bodies silently so older CLIs and browsers keep working.
  • SDK: keep the body types and methods as deprecated forwarding shims so external Go callers keep compiling. Un-deprecate the no-body methods, since they are now the canonical path.
  • CLI flag: keep --usage-app (hidden) for VS Code extension compatibility. Only the disable value still does anything.
  • Tests: remove the experiment-only tests (the UpdateUsage subtest in cli/ssh_test, WorkspaceUsageExperiment in agentapi, the Usage query tests, and app-name normalization at ingest). Collapse the metricscache and prometheus tests that looped over usage true and false. TestWorkspaceUsageTracking now checks that both no-body and legacy-body requests return 204 and record no agent stats.

Generated by Coder Agents on behalf of @f0ssel.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant