Skip to content

Commit f3253ed

Browse files
authored
Merge pull request ceph#65350 from adamemerson/wip-perfcounters-unique-string
common: Allow PerfCounters to return a provided service ID Reviewed-by: Matt Benjamin <[email protected]> Reviewed-by: Ernesto Puerta <[email protected]>
2 parents c7370e0 + 3a94a7b commit f3253ed

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

src/common/ceph_context.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,17 @@ void CephContext::_enable_perf_counter()
987987
}
988988
_mempool_perf = plb2.create_perf_counters();
989989
_perf_counters_collection->add(_mempool_perf);
990+
991+
service_unique_id = _conf.get_val<std::string>("service_unique_id");
992+
if (!service_unique_id.empty()) {
993+
PerfCountersBuilder plb(this, "service_unique_id", l_service_first,
994+
l_service_last);
995+
plb.add_u64(l_service_unique_id, service_unique_id.c_str(),
996+
"Unique ID for this service");
997+
_service_perf = plb.create_perf_counters();
998+
_perf_counters_collection->add(_service_perf);
999+
_service_perf->set(l_service_unique_id, 0);
1000+
}
9901001
}
9911002

9921003
void CephContext::_disable_perf_counter()
@@ -1003,6 +1014,12 @@ void CephContext::_disable_perf_counter()
10031014
_mempool_perf = nullptr;
10041015
_mempool_perf_names.clear();
10051016
_mempool_perf_descriptions.clear();
1017+
1018+
if (_service_perf) {
1019+
_perf_counters_collection->remove(_service_perf);
1020+
delete _service_perf;
1021+
_service_perf = nullptr;
1022+
}
10061023
}
10071024

10081025
void CephContext::_refresh_perf_values()

src/common/ceph_context.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,19 @@ class CephContext {
411411
l_mempool_items,
412412
l_mempool_last
413413
};
414+
// This is just how PerfCounters indices work, we have a bunch of
415+
// bare enums all over.
416+
enum {
417+
// Picked by grepping for the current highest value and adding 1000
418+
l_service_first = 1001000,
419+
l_service_unique_id,
420+
l_service_last
421+
};
414422
PerfCounters *_cct_perf = nullptr;
415423
PerfCounters* _mempool_perf = nullptr;
416424
std::vector<std::string> _mempool_perf_names, _mempool_perf_descriptions;
425+
std::string service_unique_id;
426+
PerfCounters* _service_perf = nullptr;
417427

418428
/**
419429
* Enable the performance counters.

src/common/config.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,9 @@ int md_config_t::parse_argv(ConfigValues& values,
715715
else if (ceph_argparse_witharg(args, i, &val, "--client_mountpoint", "-r", (char*)NULL)) {
716716
set_val_or_die(values, tracker, "client_mountpoint", val.c_str());
717717
}
718+
else if (ceph_argparse_witharg(args, i, &val, "--service_unique_id", (char*)NULL)) {
719+
set_val_or_die(values, tracker, "service_unique_id", val.c_str());
720+
}
718721
else {
719722
int r = parse_option(values, tracker, args, i, NULL, level);
720723
if (r < 0) {

src/common/options/global.yaml.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6875,3 +6875,20 @@ options:
68756875
level: dev
68766876
default: 0
68776877
desc: When EC writes should generate PDWs (development only) 0=optimal 1=never 2=when possible
6878+
- name: service_unique_id
6879+
type: str
6880+
level: advanced
6881+
desc: Unique string to be returned in PerfCounters
6882+
fmt_desc: A unique id to be created by orchestration software or the
6883+
administrator upon initial setup of a service. Enforcing uniqueness
6884+
is entirely the responsibility of the process used to create and
6885+
manage the cluster. A unique id will be unique within the scope of
6886+
the entire cluster across all services if they are chosen to be so.
6887+
note: If this is empty no uniquifier is provided.
6888+
tags:
6889+
- service
6890+
services:
6891+
- common
6892+
flags:
6893+
- no_mon_update
6894+
- startup

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,10 @@ int RGWRados::register_to_service_map(const DoutPrefixProvider *dpp, const strin
12031203
metadata["realm_name"] = svc.zone->get_realm().get_name();
12041204
metadata["realm_id"] = svc.zone->get_realm().get_id();
12051205
metadata["id"] = name;
1206+
auto service_unique_id = cct->_conf.get_val<std::string>("service_unique_id");
1207+
if (!service_unique_id.empty()) {
1208+
metadata["service_unique_id"] = std::move(service_unique_id);
1209+
}
12061210
int ret = rados.service_daemon_register(
12071211
daemon_type,
12081212
stringify(rados.get_instance_id()),

0 commit comments

Comments
 (0)