-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-8400. Expose rocksdb last sequence number through metrics #4557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also expose wal_ttl in metrics and wal_size ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
@@ -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); | ||
| } | ||
|
|
@@ -147,6 +149,7 @@ public void getMetrics(MetricsCollector metricsCollector, boolean b) { | |
| getHistogramData(rb); | ||
| getTickerTypeData(rb); | ||
| getDBPropertyData(rb); | ||
| getLatestSequenceNumber(rb); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -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); | ||
|
|
@@ -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) { | ||
|
|
@@ -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()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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