[LIVY-1070] Add LivySessionMetrics Codahale gauges for session monitoring - #543
Open
samuhasavak5 wants to merge 1 commit into
Open
[LIVY-1070] Add LivySessionMetrics Codahale gauges for session monitoring#543samuhasavak5 wants to merge 1 commit into
samuhasavak5 wants to merge 1 commit into
Conversation
Contributor
Author
|
@roczei , @gyogal , @nileshrathi345 and @ArnavBalyan Thanks..!!!! |
gyogal
reviewed
Aug 18, 2026
|
|
||
| context.mountMetricsAdminServlet("/metrics") | ||
| new LivySessionMetrics( | ||
| interactiveSessionManager, batchSessionManager, metricRegistry) |
Contributor
There was a problem hiding this comment.
The choice of syntax seems a bit unusual here, because (if I understand correctly) what ends up happening is metricRegistry.register() gets called multiple times, and the resulting LivySessionMetrics reference is not stored anywhere. Is this the convention with Codehale gauge setup, or why is LivySessionMetrics not an object for example and why is metricRegistry the last argument, even though that is what is mostly being operated on? I think those changes could make the code clearer.
gyogal
requested changes
Aug 18, 2026
samuhasavak5
force-pushed
the
LIVY-1070-livy-session-metrics
branch
2 times, most recently
from
August 18, 2026 14:00
7b3973a to
edfd4f1
Compare
…ring Register 18 livy.sessions.* session count gauges into the MetricRegistry at server startup via LivySessionMetrics.register(). Gauges reflect interactive and batch session counts by state and are exposed via the existing /metrics endpoint. Includes LivySessionMetricsSpec unit tests.
samuhasavak5
force-pushed
the
LIVY-1070-livy-session-metrics
branch
from
August 18, 2026 14:00
edfd4f1 to
810bd2d
Compare
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.
What changes were proposed in this pull request?
This PR adds server-side session monitoring gauges for LIVY-1070.
Problem: Livy exposes session state via the REST API (/sessions, /batches) but does not publish session counts as Codahale metrics on the existing /metrics endpoint. External monitoring systems must poll the REST API to observe session distribution.
Solution: Introduce LivySessionMetrics, which registers session count gauges into Livy's MetricRegistry at server startup. Gauges are derived from InteractiveSessionManager and BatchSessionManager and exposed alongside existing Livy metrics via the AdminServlet at /metrics.
Changes
Metrics registered (18 gauges)
Overall (3)
livy.sessions.totallivy.sessions.active.totallivy.sessions.terminal.totalInteractive (8)
livy.sessions.interactive.totallivy.sessions.interactive.{idle,busy,starting,shutting_down,dead,error,killed}Batch (7)
livy.sessions.batch.totallivy.sessions.batch.{starting,running,success,dead,error,killed}Design notes
getValuereturns0on exceptionshuttingdown,succeeded)Compatibility
/metricsAdminServletJIRA: https://issues.apache.org/jira/browse/LIVY-1070
How was this patch tested?
Build
Result: BUILD SUCCESS
Unit tests
Result: 8/8 tests passed
Code coverage
JaCoCo agent enabled during test run (
server/target/jacoco/main.execgenerated).No UI changes in this PR.
Was this patch authored or co-authored using generative AI tooling?
Yes, this was co-authored using Cursor to help generate the new test cases.