diff --git a/CHANGELOG.md b/CHANGELOG.md index b181dc89..7c724219 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Changelog for Management API, new PRs should update the `main / unreleased` sect ``` ## unreleased +* [BUGFIX] [#564](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/564) Fix LatencyMetrics for DSE ## v0.1.88 (2024-10-28) * [CHANGE] [#556](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/556) Update Management API dependencies to address CVEs diff --git a/management-api-agent-common/src/main/java/io/k8ssandra/metrics/builder/CassandraMetricRegistryListener.java b/management-api-agent-common/src/main/java/io/k8ssandra/metrics/builder/CassandraMetricRegistryListener.java index b74ab04f..d5e76a47 100644 --- a/management-api-agent-common/src/main/java/io/k8ssandra/metrics/builder/CassandraMetricRegistryListener.java +++ b/management-api-agent-common/src/main/java/io/k8ssandra/metrics/builder/CassandraMetricRegistryListener.java @@ -528,12 +528,21 @@ public void onTimerRemoved(String name) { */ private boolean isMicrosecondLatencyBuckets() { - // This should only catch Cassandra 4.1+ and 5+ versions. DSE 6.8 reports something like - // 4.0.0.6851 and 6.9 reports something like 4.0.0.693, both of which would follow C* 4.0.x - // nanosecond buckets - if (SERVER_MAJOR_VERSION > 4 || (SERVER_MAJOR_VERSION == 4 && SERVER_MINOR_VERSION > 0)) { + // Only Cassandra 4.1 and newer should use microsecond resolution. + + boolean isCassandra = false; + try { + Class.forName("org.apache.cassandra.utils.CassandraVersion"); + isCassandra = true; + } catch (ClassNotFoundException cfne) { + // DSE doesn't have CassandraVersion + } + if (isCassandra + && (SERVER_MAJOR_VERSION > 4 || (SERVER_MAJOR_VERSION == 4 && SERVER_MINOR_VERSION > 0))) { + logger.info("Server version indicates metrics are microsecond resolution"); return true; } + logger.info("Server version indicates metrics are nanosecond resolution"); return false; } }