mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: switch ssh session stats based on experiment (#13637)
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/dbtime"
|
||||
"github.com/coder/coder/v2/coderd/workspacestats"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
)
|
||||
|
||||
type StatsAPI struct {
|
||||
@@ -20,6 +21,7 @@ type StatsAPI struct {
|
||||
Log slog.Logger
|
||||
StatsReporter *workspacestats.Reporter
|
||||
AgentStatsRefreshInterval time.Duration
|
||||
Experiments codersdk.Experiments
|
||||
|
||||
TimeNowFn func() time.Time // defaults to dbtime.Now()
|
||||
}
|
||||
@@ -55,6 +57,16 @@ func (a *StatsAPI) UpdateStats(ctx context.Context, req *agentproto.UpdateStatsR
|
||||
slog.F("payload", req),
|
||||
)
|
||||
|
||||
if a.Experiments.Enabled(codersdk.ExperimentWorkspaceUsage) {
|
||||
// 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
|
||||
}
|
||||
|
||||
err = a.StatsReporter.ReportAgentStats(
|
||||
ctx,
|
||||
a.now(),
|
||||
|
||||
Reference in New Issue
Block a user