Add user breakdown to MCP metrics endpoint - #185
Open
seanhumessonos wants to merge 2 commits into
Open
Conversation
Author
|
Requesting a review from @olamy and @topikachu when they have a chance. |
olamy
requested changes
Jun 5, 2026
| /** | ||
| * Per-user metrics, keyed by Jenkins username (including "anonymous" and "SYSTEM"). | ||
| */ | ||
| static final ConcurrentHashMap<String, UserMetrics> userMetrics = new ConcurrentHashMap<>(); |
Member
There was a problem hiding this comment.
what happen for instance with large number of users? (possible memory leak?)
Author
There was a problem hiding this comment.
Hi @olamy
Thank you for taking a look at the PR. You're right that entries are never removed and the map grows once per unique username. Since this is bounded by the number of Jenkins users rather than by traffic, I think the memory footprint should stay small in practice (~150 bytes per user). I can add a comment to that effect if you'd like. Thoughts?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The /mcp-server/metrics endpoint previously only reported server wide aggregate counters. This change extends it to include a per-user breakdown, making it easier to identify which Jenkins accounts are actively connected and how much traffic each one is generating.
Changelist
UserMetricsinner class toMcpConnectionMetricstracking per-user SSE connections (total and active), streamable requests, and connection errorsEndpoint.javato passJenkins.getAuthentication2().getName()at all three metric recording call sites (SSE lifecycle and both streamable request paths)reset()to clear per-user metrics alongside global countersREADMEmetrics section with the new response shape and a note on the per-user breakdownTesting done
Ran unit tests in vscode:
Submitter checklist