Skip to content

Commit

Permalink
RocksdbStats should only create summary if database is open (Consensy…
Browse files Browse the repository at this point in the history
…s#9066)

Signed-off-by: Paul Harris <[email protected]>
  • Loading branch information
rolfyone authored Jan 31, 2025
1 parent 3096044 commit 7bf58da
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,27 @@ public void registerMetrics(final RocksDB database) {
+ "_"
+ histogram.name().toLowerCase(Locale.ROOT),
"RocksDB histogram for " + histogram.name(),
() -> provideExternalSummary(stats, histogram));
() -> provideExternalSummary(histogram));
}
}
}

private static ExternalSummary provideExternalSummary(
final Statistics stats, final HistogramType histogramType) {

final HistogramData data = stats.getHistogramData(histogramType);

return new ExternalSummary(
data.getCount(),
data.getSum(),
List.of(
new ExternalSummary.Quantile(0.0, data.getMin()),
new ExternalSummary.Quantile(0.5, data.getMedian()),
new ExternalSummary.Quantile(0.95, data.getPercentile95()),
new ExternalSummary.Quantile(0.99, data.getPercentile99()),
new ExternalSummary.Quantile(1.0, data.getMax())));
private ExternalSummary provideExternalSummary(final HistogramType histogramType) {
return ifOpen(
() -> {
final HistogramData data = stats.getHistogramData(histogramType);

return new ExternalSummary(
data.getCount(),
data.getSum(),
List.of(
new ExternalSummary.Quantile(0.0, data.getMin()),
new ExternalSummary.Quantile(0.5, data.getMedian()),
new ExternalSummary.Quantile(0.95, data.getPercentile95()),
new ExternalSummary.Quantile(0.99, data.getPercentile99()),
new ExternalSummary.Quantile(1.0, data.getMax())));
},
null);
}

private long getLongProperty(final RocksDB database, final String name) {
Expand Down

0 comments on commit 7bf58da

Please sign in to comment.