Expose some RocksDB stats

This commit is contained in:
Francesco Mazzoli
2023-11-09 13:23:49 +00:00
parent 03e9510255
commit c5979a9d90
8 changed files with 101 additions and 25 deletions
+10
View File
@@ -762,6 +762,7 @@ private:
CDCShared& _shared;
XmonNCAlert _alert;
MetricsBuilder _metricsBuilder;
std::unordered_map<std::string, uint64_t> _rocksDBStats;
public:
CDCMetricsInserter(Logger& logger, std::shared_ptr<XmonAgent>& xmon, CDCShared& shared):
PeriodicLoop(logger, xmon, "metrics_inserter", {1_sec, 1.0, 1_mins, 0.1}),
@@ -796,6 +797,15 @@ public:
_metricsBuilder.fieldFloat("size", (double)sum / (double)_shared.inFlightTxnsWindow.size());
_metricsBuilder.timestamp(now);
}
{
_rocksDBStats.clear();
_shared.db.rocksDBStats(_rocksDBStats);
for (const auto& [name, value]: _rocksDBStats) {
_metricsBuilder.measurement("eggsfs_cdc_rocksdb");
_metricsBuilder.fieldU64(name, value);
_metricsBuilder.timestamp(now);
}
}
std::string err = sendMetrics(10_sec, _metricsBuilder.payload());
_metricsBuilder.reset();
if (err.empty()) {
+8
View File
@@ -1666,6 +1666,10 @@ struct CDCDBImpl {
commitTransaction(*dbTxn);
}
void rocksDBStats(std::unordered_map<std::string, uint64_t>& stats) {
::rocksDBStats(_env, _db, stats);
}
};
CDCDB::CDCDB(Logger& logger, std::shared_ptr<XmonAgent>& xmon, const std::string& path) {
@@ -1695,3 +1699,7 @@ void CDCDB::startNextTransaction(bool sync, EggsTime time, uint64_t logIndex, CD
uint64_t CDCDB::lastAppliedLogEntry() {
return ((CDCDBImpl*)_impl)->_lastAppliedLogEntry();
}
void CDCDB::rocksDBStats(std::unordered_map<std::string, uint64_t>& values) {
return ((CDCDBImpl*)_impl)->rocksDBStats(values);
}
+4
View File
@@ -1,5 +1,7 @@
#pragma once
#include "unordered_map"
#include "Bincode.hpp"
#include "Msgs.hpp"
#include "Env.hpp"
@@ -129,4 +131,6 @@ public:
// The index of the last log entry persisted to the DB
uint64_t lastAppliedLogEntry();
void rocksDBStats(std::unordered_map<std::string, uint64_t>& values);
};