mirror of
https://github.com/coder/coder.git
synced 2026-11-03 05:55:24 +08:00
feat: add workspace agent session count protocol (#28125)
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.
This commit is contained in:
@@ -66,10 +66,7 @@ func (a *StatsAPI) UpdateStats(ctx context.Context, req *agentproto.UpdateStatsR
|
||||
// while the experiment is enabled we will not report
|
||||
// session stats from the agent. This is because it is
|
||||
// being handled by the CLI and the postWorkspaceUsage route.
|
||||
req.Stats.SessionCountSsh = 0
|
||||
req.Stats.SessionCountJetbrains = 0
|
||||
req.Stats.SessionCountVscode = 0
|
||||
req.Stats.SessionCountReconnectingPty = 0
|
||||
workspacestats.ClearSessionCounts(req.Stats)
|
||||
}
|
||||
|
||||
err := a.StatsReporter.ReportAgentStats(
|
||||
|
||||
@@ -525,6 +525,7 @@ func TestUpdateStats(t *testing.T) {
|
||||
batcher.Mu.Lock()
|
||||
defer batcher.Mu.Unlock()
|
||||
require.EqualValues(t, 1, batcher.Called)
|
||||
require.Empty(t, batcher.LastStats.GetSessionCounts())
|
||||
require.EqualValues(t, 0, batcher.LastStats.SessionCountSsh)
|
||||
require.EqualValues(t, 0, batcher.LastStats.SessionCountJetbrains)
|
||||
require.EqualValues(t, 0, batcher.LastStats.SessionCountVscode)
|
||||
|
||||
Reference in New Issue
Block a user