Skip to content

Add Cassandra compaction progress metrics via JMX handler#2912

Open
jkoronaAtCisco wants to merge 5 commits into
open-telemetry:mainfrom
jkoronaAtCisco:cassandra_compaction_progress
Open

Add Cassandra compaction progress metrics via JMX handler#2912
jkoronaAtCisco wants to merge 5 commits into
open-telemetry:mainfrom
jkoronaAtCisco:cassandra_compaction_progress

Conversation

@jkoronaAtCisco

Copy link
Copy Markdown

Description:

Adds two new Cassandra gauges to the JMX scraper:

  • cassandra.compaction.progress.bytes — bytes completed for in-flight compactions
  • cassandra.compaction.progress.total — total bytes for in-flight compactions

Both metrics carry taskType, keyspace, and columnfamily attributes and are grouped by that composite key. Only compactions measured in bytes are reported. Values are summed across parallel compaction tasks sharing the same key.

Implemented as a code-based ExperimentalJmxMetricHandler (SPI introduced in opentelemetry-java-instrumentation 2.29.0) because the Compactions MBean attribute requires iteration, grouping, and BigInteger string parsing — none of which can be expressed in declarative YAML rules.

Testing:

Unit tests added to cover new CassandraCompactionProgressHandler.

The Cassandra integration test was refactored to reliably produce visible compaction activity: data seeding now happens before the scraper starts, and compaction is triggered only after the scraper is running, eliminating a race condition in the original approach.

Notes:

Action required before merge: dependencyManagement/build.gradle.kts currently pins otelInstrumentationVersion = "2.29.0-alpha-SNAPSHOT". This must be updated to the stable published release (e.g. 2.29.0-alpha) before the PR is submitted, as SNAPSHOT versions are non-deterministic across CI builds and do not resolve from Maven Central.

@jkoronaAtCisco jkoronaAtCisco requested a review from a team as a code owner June 15, 2026 13:57
Copilot AI review requested due to automatic review settings June 15, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Cassandra compaction byte-progress metrics to the JMX scraper via a new code-based handler, and wires it into the Cassandra target system configuration and tests.

Changes:

  • Introduces CassandraCompactionProgressHandler emitting cassandra.compaction.progress.bytes / .total grouped by taskType, keyspace, columnfamily.
  • Registers the handler via Java SPI and Cassandra YAML, and adds unit + integration test coverage.
  • Adds an integration-test lifecycle hook to trigger long-running compactions after the scraper starts.

Reviewed changes

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

Show a summary per file
File Description
jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/handler/CassandraCompactionProgressHandler.java New handler that queries Cassandra CompactionManager and emits progress gauges.
jmx-scraper/src/main/resources/META-INF/services/io.opentelemetry.instrumentation.jmx.internal.ExperimentalJmxMetricHandler Registers the new handler via ServiceLoader.
jmx-scraper/src/main/resources/cassandra.yaml Enables the handler for the Cassandra target system.
jmx-scraper/src/test/java/io/opentelemetry/contrib/jmxscraper/handler/CassandraCompactionProgressHandlerTest.java Adds unit tests for grouping/parsing/skipping behavior.
jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TargetSystemIntegrationTest.java Adds an afterScraperStarted hook to support target-side actions post-start.
jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/CassandraIntegrationTest.java Seeds data + triggers compaction to validate new progress metrics in integration tests.
jmx-scraper/build.gradle.kts Adds Mockito dependency for new unit tests.
dependencyManagement/build.gradle.kts Updates instrumentation version to a SNAPSHOT.
CHANGELOG.md Documents the new compaction progress metrics.

}

val otelInstrumentationVersion = "2.28.1-alpha"
val otelInstrumentationVersion = "2.29.0-alpha-SNAPSHOT"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As mentioned in PR description, stable release is not released yet. Will updated it asap.

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.

2 participants