if (schema) {
f->open_object_section(d->name);
f->dump_int("type", d->type);
- if (d->description)
+
+ if (d->description) {
f->dump_string("description", d->description);
- else
+ } else {
f->dump_string("description", "");
+ }
+
+ if (d->nick != NULL) {
+ f->dump_string("nick", d->nick);
+ } else {
+ f->dump_string("nick", "");
+ }
f->close_section();
} else {
if (d->type & PERFCOUNTER_LONGRUNAVG) {
m_perf_counters = NULL;
}
-void PerfCountersBuilder::add_u64_counter(int idx, const char *name, const char *description)
+void PerfCountersBuilder::add_u64_counter(int idx, const char *name,
+ const char *description, const char *nick)
{
- add_impl(idx, name, description, PERFCOUNTER_U64 | PERFCOUNTER_COUNTER);
+ add_impl(idx, name, description, nick, PERFCOUNTER_U64 | PERFCOUNTER_COUNTER);
}
-void PerfCountersBuilder::add_u64(int idx, const char *name, const char *description)
+void PerfCountersBuilder::add_u64(int idx, const char *name,
+ const char *description, const char *nick)
{
- add_impl(idx, name, description, PERFCOUNTER_U64);
+ add_impl(idx, name, description, nick, PERFCOUNTER_U64);
}
-void PerfCountersBuilder::add_u64_avg(int idx, const char *name, const char *description)
+void PerfCountersBuilder::add_u64_avg(int idx, const char *name,
+ const char *description, const char *nick)
{
- add_impl(idx, name, description, PERFCOUNTER_U64 | PERFCOUNTER_LONGRUNAVG);
+ add_impl(idx, name, description, nick, PERFCOUNTER_U64 | PERFCOUNTER_LONGRUNAVG);
}
-void PerfCountersBuilder::add_time(int idx, const char *name, const char *description)
+void PerfCountersBuilder::add_time(int idx, const char *name,
+ const char *description, const char *nick)
{
- add_impl(idx, name, description, PERFCOUNTER_TIME);
+ add_impl(idx, name, description, nick, PERFCOUNTER_TIME);
}
-void PerfCountersBuilder::add_time_avg(int idx, const char *name, const char *description)
+void PerfCountersBuilder::add_time_avg(int idx, const char *name,
+ const char *description, const char *nick)
{
- add_impl(idx, name, description, PERFCOUNTER_TIME | PERFCOUNTER_LONGRUNAVG);
+ add_impl(idx, name, description, nick, PERFCOUNTER_TIME | PERFCOUNTER_LONGRUNAVG);
}
-void PerfCountersBuilder::add_impl(int idx, const char *name, const char *description, int ty)
+void PerfCountersBuilder::add_impl(int idx, const char *name,
+ const char *description, const char *nick, int ty)
{
assert(idx > m_perf_counters->m_lower_bound);
assert(idx < m_perf_counters->m_upper_bound);
assert(data.type == PERFCOUNTER_NONE);
data.name = name;
data.description = description;
+ data.nick = nick;
data.type = (enum perfcounter_type_d)ty;
}
perf_counter_data_any_d()
: name(NULL),
description(NULL),
- type(PERFCOUNTER_NONE),
- u64(0),
- avgcount(0),
- avgcount2(0)
+ nick(NULL),
+ type(PERFCOUNTER_NONE),
+ u64(0),
+ avgcount(0),
+ avgcount2(0)
{}
perf_counter_data_any_d(const perf_counter_data_any_d& other)
: name(other.name),
description(other.description),
- type(other.type),
- u64(other.u64.read()) {
+ nick(other.nick),
+ type(other.type),
+ u64(other.u64.read()) {
pair<uint64_t,uint64_t> a = other.read_avg();
u64.set(a.first);
avgcount.set(a.second);
const char *name;
const char *description;
+ const char *nick;
enum perfcounter_type_d type;
atomic64_t u64;
atomic64_t avgcount;
perf_counter_data_any_d& operator=(const perf_counter_data_any_d& other) {
name = other.name;
description = other.description;
+ nick = other.nick;
type = other.type;
pair<uint64_t,uint64_t> a = other.read_avg();
u64.set(a.first);
PerfCountersBuilder(CephContext *cct, const std::string &name,
int first, int last);
~PerfCountersBuilder();
- void add_u64(int key, const char *name, const char *description = NULL);
- void add_u64_counter(int key, const char *name, const char *description = NULL);
- void add_u64_avg(int key, const char *name, const char *description = NULL);
- void add_time(int key, const char *name, const char *description = NULL);
- void add_time_avg(int key, const char *name, const char *description = NULL);
+ void add_u64(int key, const char *name,
+ const char *description=NULL, const char *nick = NULL);
+ void add_u64_counter(int key, const char *name,
+ const char *description=NULL, const char *nick = NULL);
+ void add_u64_avg(int key, const char *name,
+ const char *description=NULL, const char *nick = NULL);
+ void add_time(int key, const char *name,
+ const char *description=NULL, const char *nick = NULL);
+ void add_time_avg(int key, const char *name,
+ const char *description=NULL, const char *nick = NULL);
PerfCounters* create_perf_counters();
private:
PerfCountersBuilder(const PerfCountersBuilder &rhs);
PerfCountersBuilder& operator=(const PerfCountersBuilder &rhs);
- void add_impl(int idx, const char *name, const char *description, int ty);
+ void add_impl(int idx, const char *name,
+ const char *description, const char *nick, int ty);
PerfCounters *m_perf_counters;
};
ASSERT_EQ(sd("{\"test_perfcounter_1\":{\"element1\":13,\"element2\":0.000000000,"
"\"element3\":{\"avgcount\":0,\"sum\":0.000000000}}}"), msg);
ASSERT_EQ("", client.do_request("{ \"prefix\": \"perf schema\", \"format\": \"json\" }", &msg));
-
- ASSERT_EQ(sd("{\"test_perfcounter_1\":{\"element1\":{\"type\":2,\"description\":\"\"},"
- "\"element2\":{\"type\":1,\"description\":\"\"},\"element3\":{\"type\":5,\"description\":\"\"}}}"), msg);
-
+ ASSERT_EQ(sd("{\"test_perfcounter_1\":{\"element1\":{\"type\":2,\"description\":\"\",\"nick\":\"\"},"
+ "\"element2\":{\"type\":1,\"description\":\"\",\"nick\":\"\"},\"element3\":{\"type\":5,\"description\":\"\",\"nick\":\"\"}}}"), msg);
coll->clear();
ASSERT_EQ("", client.do_request("{ \"prefix\": \"perf dump\", \"format\": \"json\" }", &msg));
ASSERT_EQ("{}", msg);