Skip to content

chore: report short-lived connections in snapshots - #3127

Open
xishang0128 wants to merge 5 commits into
MetaCubeX:Alphafrom
xishang0128:Alpha
Open

chore: report short-lived connections in snapshots#3127
xishang0128 wants to merge 5 commits into
MetaCubeX:Alphafrom
xishang0128:Alpha

Conversation

@xishang0128

Copy link
Copy Markdown
Contributor

Short-lived connections can open and close between two WebSocket updates, causing them to be missing from the connections list. This change includes them once in the next update with their final traffic statistics.

Copilot AI lite review requested due to automatic review settings August 20, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the WebSocket connections snapshot feed so that connections which open and close between two snapshot pushes are still reported once (in the next snapshot) with their final observed statistics.

Changes:

  • Add SnapshotStream to tunnel/statistic.Manager and push recently-closed TrackerInfo entries to active streams on Leave.
  • Update the WebSocket /connections route to use a per-client SnapshotStream instead of directly calling DefaultManager.Snapshot().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tunnel/statistic/manager.go Adds snapshot streaming state and logic to include closed-between-snapshots connections in the next snapshot.
hub/route/connections.go Uses a SnapshotStream for the WebSocket connections feed to include short-lived connections.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread hub/route/connections.go Outdated
Comment on lines +32 to +36
if err != nil {
return
}
snapshotStream := statistic.DefaultManager.NewSnapshotStream()
defer snapshotStream.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants