We can be quite liberal here, because mons are
small in number. However, we don't want to expose
KV database counters at this database from OSDs, so
use the prio_adjust mechanism for that.
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit
ac8320f23dd4c00eb80da0d9837c29744e38bd57)
#include <boost/scoped_ptr.hpp>
#include "include/encoding.h"
#include "common/Formatter.h"
+#include "common/perf_counters.h"
using std::string;
/**
virtual void get_statistics(Formatter *f) {
return;
}
+
+ /**
+ * Return your perf counters if you have any. Subclasses are not
+ * required to implement this, and callers must respect a null return
+ * value.
+ */
+ virtual PerfCounters *get_perf_counters() {
+ return nullptr;
+ }
protected:
/// List of matching prefixes and merge operators
std::vector<std::pair<std::string,
void close() override;
+ PerfCounters *get_perf_counters() override
+ {
+ return logger;
+ }
+
class LevelDBTransactionImpl : public KeyValueDB::TransactionImpl {
public:
leveldb::WriteBatch bat;
void split_stats(const std::string &s, char delim, std::vector<std::string> &elems);
void get_statistics(Formatter *f) override;
+ PerfCounters *get_perf_counters() override
+ {
+ return logger;
+ }
+
struct RocksWBHandler: public rocksdb::WriteBatch::Handler {
std::string seen ;
int num_seen = 0;
db->init(g_conf->mon_rocksdb_options);
else
db->init();
+
+
}
int open(ostream &out) {
r = db->open(out);
if (r < 0)
return r;
+
+ // Monitors are few in number, so the resource cost of exposing
+ // very detailed stats is low: ramp up the priority of all the
+ // KV store's perf counters. Do this after open, because backend may
+ // not have constructed PerfCounters earlier.
+ if (db->get_perf_counters()) {
+ db->get_perf_counters()->set_prio_adjust(
+ PerfCountersBuilder::PRIO_USEFUL - PerfCountersBuilder::PRIO_DEBUGONLY);
+ }
+
io_work.start();
is_open = true;
return 0;
void Paxos::init_logger()
{
PerfCountersBuilder pcb(g_ceph_context, "paxos", l_paxos_first, l_paxos_last);
+
+ // Because monitors are so few in number, the resource cost of capturing
+ // almost all their perf counters at USEFUL is trivial.
+ pcb.set_prio_default(PerfCountersBuilder::PRIO_USEFUL);
+
pcb.add_u64_counter(l_paxos_start_leader, "start_leader", "Starts in leader role");
pcb.add_u64_counter(l_paxos_start_peon, "start_peon", "Starts in peon role");
pcb.add_u64_counter(l_paxos_restart, "restart", "Restarts");