MCPcopy Create free account
hub / github.com/ceph/ceph / get_unlabeled_perf_schema_python

Method get_unlabeled_perf_schema_python

src/mgr/ActivePyModules.cc:1081–1141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1079}
1080
1081PyObject* ActivePyModules::get_unlabeled_perf_schema_python(
1082 const std::string &svc_type,
1083 const std::string &svc_id)
1084{
1085 without_gil_t no_gil;
1086 std::lock_guard l(lock);
1087
1088 DaemonStateCollection daemons;
1089
1090 if (svc_type == "") {
1091 daemons = daemon_state.get_all();
1092 } else if (svc_id.empty()) {
1093 daemons = daemon_state.get_by_service(svc_type);
1094 } else {
1095 auto key = DaemonKey{svc_type, svc_id};
1096 // so that the below can be a loop in all cases
1097 auto got = daemon_state.get(key);
1098 if (got != nullptr) {
1099 daemons[key] = got;
1100 }
1101 }
1102
1103 auto f = with_gil(no_gil, [&] {
1104 return PyFormatter();
1105 });
1106 if (!daemons.empty()) {
1107 for (auto& [key, state] : daemons) {
1108 std::lock_guard l(state->lock);
1109 with_gil(no_gil, [&, key=ceph::to_string(key), state=state] {
1110 f.open_object_section(key.c_str());
1111 for (auto ctr_inst_iter : state->perf_counters.instances) {
1112 const auto &counter_name = ctr_inst_iter.first;
1113
1114 // Ignore labeled counters. The perf schema format below can not
1115 // accomodate counters with labels. A new representation format is
1116 // requried to do support this.
1117 auto labels = ceph::perf_counters::key_labels(counter_name);
1118 if (labels.begin() != labels.end()) {
1119 continue;
1120 }
1121
1122 f.open_object_section(counter_name.c_str());
1123 auto type = state->perf_counters.types[counter_name];
1124 f.dump_string("description", type.description);
1125 if (!type.nick.empty()) {
1126 f.dump_string("nick", type.nick);
1127 }
1128 f.dump_unsigned("type", type.type);
1129 f.dump_unsigned("priority", type.priority);
1130 f.dump_unsigned("units", type.unit);
1131 f.close_section();
1132 }
1133 f.close_section();
1134 });
1135 }
1136 } else {
1137 dout(4) << __func__ << ": No daemon state found for "
1138 << svc_type << "." << svc_id << ")" << dendl;

Callers 1

Calls 15

with_gilFunction · 0.85
PyFormatterClass · 0.85
key_labelsFunction · 0.85
get_by_serviceMethod · 0.80
to_stringFunction · 0.70
get_allMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45
open_object_sectionMethod · 0.45
c_strMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected