From a4405a0c59bbf6011d643b51613addc627e8479c Mon Sep 17 00:00:00 2001 From: Ali Maredia Date: Wed, 19 Oct 2022 14:31:02 -0400 Subject: [PATCH] common: add a dump command for labeled perfcounters Signed-off-by: Ali Maredia --- src/common/ceph_context.cc | 26 ++++++++++++++++++++++++++ src/common/ceph_context.h | 5 +++++ src/common/perf_counters_cache.h | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index fe71ea4ccc49e..eeee83618819c 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -104,6 +104,12 @@ PerfCountersCollectionImpl* CephContext::get_perfcounters_collection() return _perf_counters_collection.get_perf_collection(); } +PerfCountersCollectionImpl* CephContext::get_labeledperfcounters_collection() +{ + return _labeled_perf_counters_collection.get_perf_collection(); +} + + } #else // WITH_SEASTAR namespace { @@ -544,6 +550,14 @@ int CephContext::_do_command( command == "perf schema") { _perf_counters_collection->dump_formatted(f, true); } + else if (command == "labeledperfcounters_dump" || command == "3" || + command == "labeledperf dump") { + std::string logger; + std::string counter; + cmd_getval(cmdmap, "logger", logger); + cmd_getval(cmdmap, "counter", counter); + _labeled_perf_counters_collection->dump_formatted(f, false, logger, counter); + } else if (command == "perf histogram dump") { std::string logger; std::string counter; @@ -707,6 +721,7 @@ CephContext::CephContext(uint32_t module_type_, _log_obs(NULL), _admin_socket(NULL), _perf_counters_collection(NULL), + _labeled_perf_counters_collection(NULL), _perf_counters_conf_obs(NULL), _heartbeat_map(NULL), _crypto_none(NULL), @@ -733,6 +748,7 @@ CephContext::CephContext(uint32_t module_type_, _conf.add_observer(_lockdep_obs); #endif _perf_counters_collection = new PerfCountersCollection(this); + _labeled_perf_counters_collection = new PerfCountersCollection(this); _admin_socket = new AdminSocket(this); _heartbeat_map = new HeartbeatMap(this); @@ -750,6 +766,8 @@ CephContext::CephContext(uint32_t module_type_, _admin_socket->register_command("perf histogram dump name=logger,type=CephString,req=false name=counter,type=CephString,req=false", _admin_hook, "dump perf histogram values"); _admin_socket->register_command("2", _admin_hook, ""); _admin_socket->register_command("perf schema", _admin_hook, "dump perfcounters schema"); + _admin_socket->register_command("labeledperf dump name=logger,type=CephString,req=false name=counter,type=CephString,req=false", _admin_hook, "dump labeled perfcounters value"); + _admin_socket->register_command("3", _admin_hook, ""); _admin_socket->register_command("perf histogram schema", _admin_hook, "dump perf histogram schema"); _admin_socket->register_command("perf reset name=var,type=CephString", _admin_hook, "perf reset : perf reset all or one perfcounter name"); _admin_socket->register_command("config show", _admin_hook, "dump current config settings"); @@ -797,6 +815,9 @@ CephContext::~CephContext() delete _perf_counters_collection; _perf_counters_collection = NULL; + delete _labeled_perf_counters_collection; + _labeled_perf_counters_collection = NULL; + delete _perf_counters_conf_obs; _perf_counters_conf_obs = NULL; @@ -926,6 +947,11 @@ PerfCountersCollection *CephContext::get_perfcounters_collection() return _perf_counters_collection; } +PerfCountersCollection *CephContext::get_labeledperfcounters_collection() +{ + return _labeled_perf_counters_collection; +} + void CephContext::_enable_perf_counter() { assert(!_cct_perf); diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h index f1877647877ab..90eb926721211 100644 --- a/src/common/ceph_context.h +++ b/src/common/ceph_context.h @@ -89,6 +89,7 @@ public: } CryptoRandom* random() const; PerfCountersCollectionImpl* get_perfcounters_collection(); + PerfCountersCollectionImpl* get_labeledperfcounters_collection(); crimson::common::ConfigProxy& _conf; crimson::common::PerfCountersCollection& _perf_counters_collection; CephContext* get(); @@ -169,6 +170,9 @@ public: /* Get the PerfCountersCollection of this CephContext */ PerfCountersCollection *get_perfcounters_collection(); + /* Get the PerfCountersCollection of this CephContext */ + PerfCountersCollection *get_labeledperfcounters_collection(); + ceph::HeartbeatMap *get_heartbeat_map() { return _heartbeat_map; } @@ -325,6 +329,7 @@ private: /* The collection of profiling loggers associated with this context */ PerfCountersCollection *_perf_counters_collection; + PerfCountersCollection *_labeled_perf_counters_collection; md_config_obs_t *_perf_counters_conf_obs; diff --git a/src/common/perf_counters_cache.h b/src/common/perf_counters_cache.h index 833f583795080..b7b37cb7dfe3c 100644 --- a/src/common/perf_counters_cache.h +++ b/src/common/perf_counters_cache.h @@ -60,7 +60,7 @@ public: plb.add_u64_counter(l_rgw_metrics_get_b, "get_b", "Size of gets"); PerfCounters *counters = plb.create_perf_counters(); - cct->get_perfcounters_collection()->add(counters); + cct->get_labeledperfcounters_collection()->add(counters); ref->perfcounters_instance = counters; //ref->collection = cct->get_perfcounters_collection(); //ref->collection->add(counters); -- 2.39.5