Mmuzaf commented on code in PR #3742:
URL: https://github.com/apache/cassandra/pull/3742#discussion_r1913613516
##########
src/java/org/apache/cassandra/tools/nodetool/stats/TableStatsHolder.java:
##########
@@ -393,12 +404,59 @@ private void initializeKeyspaces(NodeProbe probe, boolean
ignore, List<String> t
if (table.getTopTombstonePartitionsLastUpdate() != null)
statsTable.topTombstonePartitionsLastUpdate =
millisToDateString(table.getTopTombstonePartitionsLastUpdate());
+ if (!SchemaConstants.isSystemKeyspace(keyspaceName))
+ {
+ if (table.hasStorageAttachedIndex())
+ {
+ Object queryLatencyMetric =
probe.getSaiMetric(keyspaceName, tableName, "QueryLatency");
+ double QueryLatency =
getMetricMean(queryLatencyMetric);
+ statsTable.saiQueryLatencyMs = QueryLatency > 0 ?
QueryLatency : Double.NaN;
+
+ Object PostFilteringReadLatency =
probe.getSaiMetric(keyspaceName, tableName, "PostFilteringReadLatency");
+ double postfilteringreadlatency =
getMetricMean(PostFilteringReadLatency);
+ statsTable.saiPostFilteringReadLatencyms =
postfilteringreadlatency > 0 ? postfilteringreadlatency : Double.NaN;
+
+ Object diskUsedBytes =
probe.getSaiMetric(keyspaceName, tableName, "DiskUsedBytes");
+ long saidiskusedbytes = (diskUsedBytes != null) ?
(long) diskUsedBytes : 0L;
+ statsTable.saiDiskUsedBytes =
FileUtils.stringifyFileSize(saidiskusedbytes, humanReadable);
+
+ Object SSTableIndexesHit =
probe.getSaiMetric(keyspaceName, tableName, "SSTableIndexesHit");
+ statsTable.saiSSTableIndexesHit =
getMetricMean(SSTableIndexesHit);
+
+ Object IndexSegmentsHit =
probe.getSaiMetric(keyspaceName, tableName, "IndexSegmentsHit");
+ statsTable.saiIndexSegmentsHit =
getMetricMean(IndexSegmentsHit);
+
+ Object RowsFiltered = probe.getSaiMetric(keyspaceName,
tableName, "RowsFiltered");
+ statsTable.saiRowsFiltered =
getMetricMean(RowsFiltered);
+
+ Object totalQueryTimeouts =
probe.getSaiMetric(keyspaceName, tableName, "TotalQueryTimeouts");
+ statsTable.saiTotalQueryTimeouts = (totalQueryTimeouts
!= null) ? (Long) totalQueryTimeouts : 0L;
+
+ Object totalIndexCount =
probe.getSaiMetric(keyspaceName, tableName, "TotalIndexCount");
+ statsTable.saiTotalIndexCount = (totalIndexCount !=
null) ? (int) totalIndexCount : 0;
+
+ Object totalQueryableIndexCount =
probe.getSaiMetric(keyspaceName, tableName, "TotalQueryableIndexCount");
+ int saiTotalQueryableIndexCount =
(totalQueryableIndexCount != null) ? (int) totalQueryableIndexCount : 0;
+
+ statsTable.saiTotalQueryableIndexRatio =
String.format("%d/%d", statsTable.saiTotalIndexCount,
saiTotalQueryableIndexCount);
+ }
+ }
statsKeyspace.tables.add(statsTable);
}
keyspaces.add(statsKeyspace);
}
}
+ private double getMetricMean(Object metricObject) {
+ if (metricObject instanceof CassandraMetricsRegistry.JmxTimerMBean) {
+ return ((CassandraMetricsRegistry.JmxTimerMBean)
metricObject).getMean() / 1000;
+ }
+ if (metricObject instanceof
CassandraMetricsRegistry.JmxHistogramMBean) {
+ return Math.round(((CassandraMetricsRegistry.JmxHistogramMBean)
metricObject).getMean() * 100.0) / 100.0;
+ }
+ return Double.NaN;
Review Comment:
Why should we return `NaN` if we query a metric of the wrong type that
doesn't have 'mean' value? We should throw an exception and fail in that case,
which would mean the method call is incorrect.
##########
src/java/org/apache/cassandra/index/sai/metrics/IndexGroupMetrics.java:
##########
@@ -25,6 +25,7 @@
public class IndexGroupMetrics extends AbstractMetrics
{
+ public static final String INDEX_GROUP_METRICS_TYPE = "IndexGroupMetrics";
public IndexGroupMetrics(TableMetadata table, StorageAttachedIndexGroup
group)
{
super(table.keyspace, table.name, "IndexGroupMetrics");
Review Comment:
We could use the `INDEX_GROUP_METRICS_TYPE` constant here for the `scope`
field (applies to all other similar
places).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]