Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: zero out session stats from agent with experiment enabled #13579

Closed
wants to merge 14 commits into from

Conversation

f0ssel
Copy link
Contributor

@f0ssel f0ssel commented Jun 14, 2024

This moves the responsibility for reporting ssh session stats from the agent to the cli ssh command.

  • agentapi - Adds new GetExperiments endpoint so agents can query active experiments. AgentAPI Version bumped to 2.2.
  • agent - Now queries experiments before starting stats report loop. If workspace_usage experiment is enabled we will zero out SSH session stats before sending it to coderd.
  • cli - Connecting to a new SSH session will now regularly push to workspace usage endpoint, which will write ssh session stats if the experiment is enabled.

@f0ssel f0ssel marked this pull request as draft June 14, 2024 20:03
@f0ssel f0ssel changed the title chore: stop saving session stats with experiment chore: stop saving session stats with experiment + ssh usage tracking Jun 17, 2024
@f0ssel f0ssel marked this pull request as ready for review June 18, 2024 17:08
@f0ssel f0ssel changed the title chore: stop saving session stats with experiment + ssh usage tracking chore: move ssh session tracking from agent to cli Jun 18, 2024
agent/stats.go Outdated Show resolved Hide resolved
agent/stats.go Show resolved Hide resolved
Comment on lines +126 to +127
// if the experiment is enabled we zero out certain session stats
// as we migrate to the client reporting these stats instead.
Copy link
Member

Choose a reason for hiding this comment

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

Can this get implemented serverside instead? It seems like a lot of changes in the agent for something that could be zeroed out in the stats API on the server.

Copy link
Member

Choose a reason for hiding this comment

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

+1, this would keep the change in 'one place' and remove the need for plumbing this through AgentAPI

Copy link
Contributor Author

@f0ssel f0ssel Jun 20, 2024

Choose a reason for hiding this comment

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

Not really and here's why - If customers update coder but do not rebuild the workspace, we will have an old agent client and old cli version in the workspace. If the experiment is enabled and we zero out the value server side, we will lose data for that workspace because the old cli will not be reporting the new data via the usage endpoint. So the graphs will go to zero and slowly come back up over time as each workspace is restarted.

So we need the endpoint to still save this data for old workspaces, but also allow new workspaces to report it in the new way. Or we accept downtime on the stats on upgrade until all workspaces are updated. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

If the experiment is enabled and we zero out the value server side, we will lose data for that workspace because the old cli will not be reporting the new data via the usage endpoint.

Won't the same thing happen even if the feature was GA? Old agent/CLI versions need to be supported on new servers for multiple months.

This will also affect stats collection for older CLIs being used outside of workspaces, which arguably is where more people use the CLI anyways. I don't think anyone is using the CLI in a workspace to connect to a workspace.

So we need the endpoint to still save this data for old workspaces, but also allow new workspaces to report it in the new way. Or we accept downtime on the stats on upgrade until all workspaces are updated.

I think either way there will be a "downtime" of stats with or without the agent changes when an older CLI is being used on the local machine.

I think this PR should change into just the CLI stats upload portion and have both sides report stats for now. Then in a few months you can remove stats reporting from the API by deprecating the field and ignoring it serverside.

coderd/workspacestats/wstest/batcher.go Outdated Show resolved Hide resolved
agent/proto/agent.proto Show resolved Hide resolved
Comment on lines +126 to +127
// if the experiment is enabled we zero out certain session stats
// as we migrate to the client reporting these stats instead.
Copy link
Member

Choose a reason for hiding this comment

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

+1, this would keep the change in 'one place' and remove the need for plumbing this through AgentAPI

@f0ssel f0ssel changed the title chore: move ssh session tracking from agent to cli chore: zero out session stats from agent with experiment enabled Jun 22, 2024
@f0ssel
Copy link
Contributor Author

f0ssel commented Jun 22, 2024

Closing due to release rollout issues in favor of #13635

@f0ssel f0ssel closed this Jun 22, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2024
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.

None yet

3 participants