fix: record left status in jenkins.queue.count metric and add queue metrics test#1271
Open
kanagaabishek wants to merge 2 commits intojenkinsci:mainfrom
Open
fix: record left status in jenkins.queue.count metric and add queue metrics test#1271kanagaabishek wants to merge 2 commits intojenkinsci:mainfrom
kanagaabishek wants to merge 2 commits intojenkinsci:mainfrom
Conversation
… metrics test Issue jenkinsci#1174: The 'left' queue item status was counted in the batchCallback but never recorded to the queueItems ObservableLongMeasurement, making the 'left' status invisible in the jenkins.queue.count metric. This commit: - Records left items with STATUS='left' in the queueItems gauge - Adds MonitoringQueueListenerTest verifying all queue metrics are registered and exported after a job completes Fixes: jenkinsci#1174
Author
|
I noticed PR #1240 also addresses #1174 by fixing ACL-restricted queue visibility. My PR addresses a separate gap: the left status is counted via AtomicInteger left but the corresponding queueItems.record(left.get(), ...) call was never written, so jenkins.queue.count{status="left"} is always absent regardless of ACL context. These two fixes address different failure modes of the same issue — #1240 fixes visibility under restricted auth, this PR fixes completeness of the left dimension. Happy to rebase on top of #1240 if the maintainers prefer a combined fix. |
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.
… metrics test
Issue #1174: The 'left' queue item status was counted in the batchCallback but never recorded to the queueItems ObservableLongMeasurement, making the 'left' status invisible in the jenkins.queue.count metric.
This commit:
Fixes: #1174
Fixes #1174
The
leftqueue item status was counted inside thebatchCallbackinMonitoringQueueListenerbut was never recorded to thequeueItemsObservableLongMeasurement. This meant theleftstatus was silentlydropped from the
jenkins.queue.countmetric while all other statuses(blocked, buildable, stuck, waiting) were correctly recorded.
Root cause
In
MonitoringQueueListener.postConstruct(), the batch callback tracksleftitems viaAtomicInteger leftand increments it correctly, butthe corresponding
queueItems.record(left.get(), Attributes.of(STATUS, "left"))call was missing. Every other status had its recording call —
leftdid not.Changes
MonitoringQueueListener.java: addedqueueItems.record(left.get(), Attributes.of(STATUS, "left"))alongside the existing status recordingsMonitoringQueueListenerTest.java: first dedicated test for queue metrics — verifies all six queue metrics (jenkins.queue.count,jenkins.queue.waiting,jenkins.queue.blocked,jenkins.queue.buildable,jenkins.queue.left,jenkins.queue.time_spent_millis) are registered and exported after a job completesTesting done
Added
MonitoringQueueListenerTest— the first automated test for queue metrics.The test:
forceFlush().join(10, TimeUnit.SECONDS)jenkins.queue.leftcounter value is >= 1 after the job completesTo run:
./mvnw test -Dtest="MonitoringQueueListenerTest"
Test passes locally on Java 21 / Maven 3.9.9.
Submitter checklist