From: Naveen Naidu Date: Wed, 19 Mar 2025 13:43:47 +0000 (+0530) Subject: mgr: do not ignore labeled perf counters in MMgrReport X-Git-Tag: v20.3.0~45^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f941025561ecd6e42b032980d77555ef2540aa70;p=ceph.git mgr: do not ignore labeled perf counters in MMgrReport The labeled perf counters are now included in the MMgrReport sent from MgrClients. The 'get_unlabeled_perf_schema_python' is also updated to ignore labeled counters, since labels counters requires new representation format not supported by the current logic. Signed-off-by: Naveen Naidu --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 5a0fa1c817aa..33a82e53c4d9 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -19,6 +19,7 @@ #include #include "common/errno.h" +#include "common/perf_counters_key.h" #include "crush/CrushWrapper.h" #include "include/stringify.h" @@ -964,8 +965,17 @@ PyObject* ActivePyModules::get_unlabeled_perf_schema_python( f.open_object_section(key.c_str()); for (auto ctr_inst_iter : state->perf_counters.instances) { const auto &counter_name = ctr_inst_iter.first; - f.open_object_section(counter_name.c_str()); - auto type = state->perf_counters.types[counter_name]; + + // Ignore labeled counters. The perf schema format below can not + // accomodate counters with labels. A new representation format is + // requried to do support this. + auto labels = ceph::perf_counters::key_labels(counter_name); + if (labels.begin() != labels.end()) { + continue; + } + + f.open_object_section(counter_name.c_str()); + auto type = state->perf_counters.types[counter_name]; f.dump_string("description", type.description); if (!type.nick.empty()) { f.dump_string("nick", type.nick); diff --git a/src/mgr/ActivePyModules.h b/src/mgr/ActivePyModules.h index cb2587b1be82..172fc85694c5 100644 --- a/src/mgr/ActivePyModules.h +++ b/src/mgr/ActivePyModules.h @@ -96,21 +96,21 @@ public: const std::string &svc_id, const std::string &path); PyObject *get_latest_unlabeled_counter_python( - const std::string &svc_type, - const std::string &svc_id, - const std::string &path); + const std::string &svc_type, + const std::string &svc_id, + const std::string &path); PyObject *get_unlabeled_perf_schema_python( - const std::string &svc_type, - const std::string &svc_id); + const std::string &svc_type, + const std::string &svc_id); PyObject *get_rocksdb_version(); PyObject *get_context(); PyObject *get_osdmap(); /// @note @c fct is not allowed to acquire locks when holding GIL PyObject *with_unlabled_perf_counters( std::function fct, + PerfCounterInstance &counter_instance, + PerfCounterType &counter_type, + PyFormatter &f)> fct, const std::string &svc_name, const std::string &svc_id, const std::string &path) const; diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 99c9abba8c91..ebdd6f4c2686 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -1485,7 +1485,7 @@ PyMethodDef BaseMgrModule_methods[] = { "Get a performance counter"}, {"_ceph_get_latest_unlabeled_counter", (PyCFunction)get_latest_unlabeled_counter, METH_VARARGS, - "Get the latest performance counter"}, + "Fetch (or get) the latest (or updated) value of an unlabeled counter"}, {"_ceph_get_unlabeled_perf_schema", (PyCFunction)get_unlabeled_perf_schema, METH_VARARGS, "Get the unlabeled performance counter schema"}, diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 01dbf2914eb4..23843622b386 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -330,15 +330,8 @@ void MgrClient::_send_report() { // Helper for checking whether a counter should be included auto include_counter = [this]( - const PerfCounters::perf_counter_data_any_d &ctr, - const PerfCounters &perf_counters) - { - // FIXME: We don't send labeled perf counters to the mgr currently. - auto labels = ceph::perf_counters::key_labels(perf_counters.get_name()); - if (labels.begin() != labels.end()) { - return false; - } - + const PerfCounters::perf_counter_data_any_d &ctr, + const PerfCounters &perf_counters) { return perf_counters.get_adjusted_priority(ctr.prio) >= (int)stats_threshold; };