Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[LIVY-1070] Gate session metrics behind livy.server.session-metrics.enabled - #553

Open
samuhasavak5 wants to merge 1 commit into
apache:masterfrom
samuhasavak5:LIVY-1070-session-metrics-opt-in
Open

[LIVY-1070] Gate session metrics behind livy.server.session-metrics.enabled#553
samuhasavak5 wants to merge 1 commit into
apache:masterfrom
samuhasavak5:LIVY-1070-session-metrics-opt-in

Conversation

@samuhasavak5

@samuhasavak5 samuhasavak5 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR adds an opt-in configuration flag for LIVY-1070 session monitoring gauges (follow-up to #543).

Problem: PR #543 always registers LivySessionMetrics at server startup. Operators and downstream distributions need per-deployment control — session gauges should be disabled by default and enabled only when monitoring is desired.

Solution: Introduce livy.server.session-metrics.enabled (default false). When true, LivySessionMetrics.register() runs at startup (same behavior as #543). When false, the /metrics/metrics servlet remains available but livy.sessions.* gauges are not published.

Changes

File Change
LivyConf.scala Add SESSION_METRICS_ENABLED config entry
LivyServer.scala Gate LivySessionMetrics.register() behind config flag
LivySessionMetricsSpec.scala Unit tests (+1 case: default disabled)
docs/rest-api.md Document opt-in behavior for /metrics/metrics
conf/livy.conf.template Commented example config

No changes to LivySessionMetrics.scala — the 18 gauges implementation remains as merged in #543.

Configuration

Default: opt-in disabled
livy.server.session-metrics.enabled=false

Enable session gauges (same 18 gauges as #543)
livy.server.session-metrics.enabled=true

Behavior when enabled (livy.server.session-metrics.enabled=true)

Same 18 gauges as #543:

Overall (3)

  • livy.sessions.total
  • livy.sessions.active.total
  • livy.sessions.terminal.total

Interactive (8)

  • livy.sessions.interactive.total
  • livy.sessions.interactive.{idle,busy,starting,shutting_down,dead,error,killed}

Batch (7)

  • livy.sessions.batch.total
  • livy.sessions.batch.{starting,running,success,dead,error,killed}

Design notes

Compatibility

JIRA: https://issues.apache.org/jira/browse/LIVY-1070

How was this patch tested?

Build

mvn package -Pspark3 -Pscala-2.12 -pl server -am
-s /tmp/livy-mvn-central-settings.xml -DskipTests

Result: BUILD SUCCESS

Unit tests

mvn test -Pspark3 -Pscala-2.12 -pl server
-s /tmp/livy-mvn-central-settings.xml
-Dsuites=org.apache.livy.server.LivySessionMetricsSpec

Result: 9/9 tests passed

Test Coverage
Default session metrics disabled in LivyConf Opt-in default
All 18 gauge registrations Registration
Duplicate registration guard Idempotency
Zero sessions Empty state
Interactive sessions by state State counting
Batch sessions by state (incl. succeeded alias) State counting
Batch succeeded alias Edge case
Overall totals (total, active, terminal) Aggregation
Exception fallback returns 0 Error handling

Code coverage

JaCoCo agent enabled during test run (server/target/jacoco/main.exec generated).

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 case and documentation.

…nabled

Follow-up to apache#543. Add livy.server.session-metrics.enabled (default false)
so livy.sessions.* gauges are only registered when explicitly enabled.
Document opt-in behavior in rest-api.md and livy.conf.template.
@samuhasavak5

Copy link
Copy Markdown
Contributor Author

@roczei , @gyogal , @nileshrathi345 and @ArnavBalyan
could you please take a look when possible and review

Thanks..!!!!

@samuhasavak5 samuhasavak5 changed the title [LIVY-1070] Gate session metrics behind livy.server.session-metrics.nabled [LIVY-1070] Gate session metrics behind livy.server.session-metrics.enabled Sep 11, 2026
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.

1 participant