Skip to content

feat(vmcp): log active sessions on creation, expiry, and periodically#4019

Open
yrobla wants to merge 2 commits intomainfrom
issue-3876
Open

feat(vmcp): log active sessions on creation, expiry, and periodically#4019
yrobla wants to merge 2 commits intomainfrom
issue-3876

Conversation

@yrobla
Copy link
Contributor

@yrobla yrobla commented Mar 5, 2026

Log session lifecycle events and periodic active session counts for operational debugging and compliance auditing when sessionManagementV2 is enabled.

Changes

  • Manager.CreateSession(): upgraded log to Info with session ID, backend count, and backend names
  • Manager.Terminate(): log Info with session ID and backend count when a MultiSession expires; separate log for placeholder termination
  • Manager.StartPeriodicLogging(ctx, interval): new method that starts a background goroutine logging active session counts every minute
  • Manager.logActiveSessions(): internal helper that iterates sessions via Range(), aggregates per-backend session counts, and logs a summary; logs a one-time warning when distributed storage makes enumeration unavailable
  • Server.Start(): calls StartPeriodicLogging when SessionManagementV2 is enabled

Removed

  • /status endpoint session fields (Sessions, SessionsStatus, BackendUsage) — session data is now surfaced through logs only
  • ListActiveSessions() from SessionManager interface

Closes: #3876

@yrobla yrobla requested a review from Copilot March 5, 2026 15:28
@github-actions github-actions bot added the size/M Medium PR: 300-599 lines changed label Mar 5, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00fd4857c7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds session visibility to the vMCP /status endpoint to support operational debugging and compliance auditing when SessionManagementV2 is enabled.

Changes:

  • Extend /status response schema to optionally include active vMCP sessions and backend session ID mappings.
  • Add ListActiveSessions() to the session manager and expose the data through buildStatusResponse.
  • Add unit tests for ListActiveSessions() behavior and a regression test that sessions is omitted when V2 is disabled.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/vmcp/server/status.go Adds optional sessions block to /status when SessionManagementV2 is enabled.
pkg/vmcp/server/status_test.go Updates status response test DTOs; adds tests for sessions omission and backend field redaction.
pkg/vmcp/server/sessionmanager/session_manager.go Introduces SessionInfo and implements ListActiveSessions().
pkg/vmcp/server/sessionmanager/list_sessions_test.go Adds tests for listing behavior across empty, placeholder-only, and populated stores.
pkg/vmcp/server/session_manager_interface.go Extends the SessionManager interface with ListActiveSessions().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 28.12500% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.63%. Comparing base (0791876) to head (3ad3eae).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/server/sessionmanager/session_manager.go 33.96% 35 Missing ⚠️
pkg/vmcp/server/server.go 0.00% 7 Missing and 1 partial ⚠️
pkg/transport/session/manager.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4019   +/-   ##
=======================================
  Coverage   68.62%   68.63%           
=======================================
  Files         445      445           
  Lines       45374    45426   +52     
=======================================
+ Hits        31140    31178   +38     
- Misses      11827    11843   +16     
+ Partials     2407     2405    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 5, 2026
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/M Medium PR: 300-599 lines changed labels Mar 6, 2026
Copy link
Contributor

@jerm-dro jerm-dro left a comment

Choose a reason for hiding this comment

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

Is this change really necessary? I get that it'd be nice to have visibility into active sessions, but exposing an endpoint seems heavy-handed. Alternative approaches:

  • periodically log all the active sessions in memory
  • log sessions as they are created and expired

What do you think?

@yrobla yrobla changed the title feat(vmcp): expose active backend sessions on /status endpoint feat(vmcp): log active sessions on creation, expiry, and periodically Mar 9, 2026
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/L Large PR: 600-999 lines changed size/S Small PR: 100-299 lines changed labels Mar 9, 2026
Add session visibility to the /status endpoint for operational debugging
and compliance auditing when sessionManagementV2 is enabled.

Closes: #3876
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 9, 2026
@yrobla
Copy link
Contributor Author

yrobla commented Mar 9, 2026

Is this change really necessary? I get that it'd be nice to have visibility into active sessions, but exposing an endpoint seems heavy-handed. Alternative approaches:

  • periodically log all the active sessions in memory
  • log sessions as they are created and expired

What do you think?

ok this task came generated by claude, based on the rfc. A bit overkill, i agree. So i modified the issue to log content, as you were saying, and i modified the pr.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Replace the /status endpoint session fields with structured logging:
- CreateSession logs Info with session ID, backend count, and names
- Terminate logs Info with session ID and backend count on expiry
- StartPeriodicLogging starts a background goroutine that logs active
  session counts every minute via logActiveSessions()
- Server.Start() wires up periodic logging when SessionManagementV2 is on

Remove ListActiveSessions() from the SessionManager interface and drop
the /status session fields (Sessions, SessionsStatus, BackendUsage).

Closes: #3876

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

fix(vmcp): drop else after return in Terminate (revive lint)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yrobla yrobla requested review from ChrisJBurns and blkt as code owners March 9, 2026 11:18
@github-actions github-actions bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Mar 9, 2026
Comment on lines +222 to +228
// SupportsRange reports whether the current storage backend supports Range().
// Returns true only for LocalStorage; distributed backends (Redis, Valkey) return false.
func (m *Manager) SupportsRange() bool {
_, ok := m.storage.(*LocalStorage)
return ok
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Blocker: How about we wait to implement this until we can support all session storage types?

We're imminently going to introduce Redis storage. That will come along with a LRU cache for in-memory sessions. That will be easier to instrument in a way that works for single and multi replica use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vMCP] Expose active backend sessions on health endpoint

4 participants