Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public class RocksDBStoreMetrics implements MetricsSource {
private static final String NUM_FILES_AT_LEVEL = "num_files_at_level";
private static final String SIZE_AT_LEVEL = "size_at_level";

private static final String LAST_SEQUENCE_NUMBER = "last_sequence_number";

Choose a reason for hiding this comment

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

Looks straightforward change introducing LAST_SEQUENCE_NUMBER metrics. On similar lines as HistogramData,TickerTypeData,PropertyData we have introduced getLatestSequenceNumber and updating metrics with calling getLatestSequenceNumber via getMetrics.

Copy link

@krishnaasawa1 krishnaasawa1 Apr 12, 2023

Choose a reason for hiding this comment

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

@ArafatKhan2198 @devmadhuu Please Review as metrics related

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also expose wal_ttl in metrics and wal_size ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@devmadhuu , wal_ttl and wal_size value are statically configured value. They can be retrieved from the rocksdb MANIFEST file.


public RocksDBStoreMetrics(Statistics statistics, RocksDatabase db,
String dbName) {
this.contextName = ROCKSDB_CONTEXT_PREFIX + dbName;
Expand All @@ -130,7 +132,7 @@ public static RocksDBStoreMetrics create(Statistics statistics,
MetricsSystem ms = DefaultMetricsSystem.instance();
MetricsSource metricsSource = ms.getSource(metrics.contextName);
if (metricsSource != null) {
return (RocksDBStoreMetrics)metricsSource;
return (RocksDBStoreMetrics) metricsSource;
} else {
return ms.register(metrics.contextName, "RocksDB Metrics", metrics);
}
Expand All @@ -147,6 +149,7 @@ public void getMetrics(MetricsCollector metricsCollector, boolean b) {
getHistogramData(rb);
getTickerTypeData(rb);
getDBPropertyData(rb);
getLatestSequenceNumber(rb);
}

/**
Expand All @@ -168,7 +171,7 @@ private void getHistogramData(MetricsRecordBuilder rb) {
try {
Method method =
HistogramData.class.getMethod("get" + histogramAttribute);
double metricValue = (double) method.invoke(histogram);
double metricValue = (double) method.invoke(histogram);
rb.addGauge(Interns.info(histogramType.name() + "_" +
histogramAttribute.toUpperCase(), "RocksDBStat"),
metricValue);
Expand Down Expand Up @@ -247,7 +250,7 @@ private Map<String, Map<Integer, Map<String, Long>>> computeSstFileStat() {
Map<Integer, Map<String, Long>> sizeStatPerCF = new HashMap<>();
Map<String, Long> numStat;
Map<String, Long> sizeStat;
for (LiveFileMetaData file: liveFileMetaDataList) {
for (LiveFileMetaData file : liveFileMetaDataList) {
numStat = numStatPerCF.get(file.level());
String cf = Strings.fromByteArray(file.columnFamilyName());
if (numStat != null) {
Expand Down Expand Up @@ -281,10 +284,15 @@ private void exportSstFileStat(MetricsRecordBuilder rb,
for (Map.Entry<Integer, Map<String, Long>> entry: numStatPerCF.entrySet()) {
numStat = entry.getValue();
numStat.forEach((cf, v) -> rb.addCounter(Interns.info(
cf + "_" + metricName + entry.getKey(), "RocksDBProperty"), v));
cf + "_" + metricName + entry.getKey(), "RocksDBProperty"), v));
rb.addCounter(
Interns.info(metricName + entry.getKey(), "RocksDBProperty"),
numStat.values().stream().mapToLong(p -> p.longValue()).sum());
}
}

private void getLatestSequenceNumber(MetricsRecordBuilder rb) {
rb.addCounter(Interns.info(LAST_SEQUENCE_NUMBER, "RocksDBStat"),
rocksDB.getLatestSequenceNumber());
}
}