Skip to content

Commit d83f4eb

Browse files
authored
fix: stop activity bump if no tracked sessions (coder#15237)
Part of coder#15176 I originally kept this the same because I wanted to be conservative about when we start dropping activity, but this is proving to be a problem when using `coder ssh` with `--usage-app=disabled`. Because the workspace agent still counts this as a connection (I think it still should so it's counted somewhere) but not as a SSH / IDE session. This leads to background ssh tasks that want to be untracked still continuing to bump activity when it shouldn't. This makes it so we have to have an explicit session to bump activity.
1 parent ceb168b commit d83f4eb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

coderd/workspacestats/reporter.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func (r *Reporter) ReportAppStats(ctx context.Context, stats []workspaceapps.Sta
117117
return nil
118118
}
119119

120+
// nolint:revive // usage is a control flag while we have the experiment
120121
func (r *Reporter) ReportAgentStats(ctx context.Context, now time.Time, workspace database.Workspace, workspaceAgent database.WorkspaceAgent, templateName string, stats *agentproto.Stats, usage bool) error {
121122
// update agent stats
122123
r.opts.StatsBatcher.Add(now, workspaceAgent.ID, workspace.TemplateID, workspace.OwnerID, workspace.ID, stats, usage)
@@ -136,8 +137,13 @@ func (r *Reporter) ReportAgentStats(ctx context.Context, now time.Time, workspac
136137
}, stats.Metrics)
137138
}
138139

139-
// if no active connections we do not bump activity
140-
if stats.ConnectionCount == 0 {
140+
// workspace activity: if no sessions we do not bump activity
141+
if usage && stats.SessionCountVscode == 0 && stats.SessionCountJetbrains == 0 && stats.SessionCountReconnectingPty == 0 && stats.SessionCountSsh == 0 {
142+
return nil
143+
}
144+
145+
// legacy stats: if no active connections we do not bump activity
146+
if !usage && stats.ConnectionCount == 0 {
141147
return nil
142148
}
143149

0 commit comments

Comments
 (0)