Skip to content

Commit

Permalink
should fix histogram
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Harris <[email protected]>
  • Loading branch information
rolfyone committed Jan 31, 2025
1 parent 7e6b4ac commit 2203fc9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ public static KvStoreAccessor create(
final ColumnFamilyOptions columnFamilyOptions =
createColumnFamilyOptions(configuration, blockCache);
final List<AutoCloseable> resources =
new ArrayList<>(List.of(txOptions, dbOptions, columnFamilyOptions, blockCache));
new ArrayList<>(
List.of(txOptions, dbOptions, columnFamilyOptions, rocksDbStats, blockCache));

List<ColumnFamilyDescriptor> columnDescriptors =
createColumnFamilyDescriptors(columns, deletedColumns, columnFamilyOptions);
Expand Down Expand Up @@ -109,7 +110,6 @@ public static KvStoreAccessor create(
final ImmutableMap<KvStoreColumn<?, ?>, ColumnFamilyHandle> columnHandlesMap =
builder.build();
final ColumnFamilyHandle defaultHandle = getDefaultHandle(columnHandles);
resources.add(rocksDbStats);
resources.add(db);

rocksDbStats.registerMetrics(db);
Expand Down
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 2203fc9

Please sign in to comment.