if (schema) {
f->open_object_section(d->name);
+ // we probably should not have exposed this raw field (with bit
+ // values), but existing plugins rely on it so we're stuck with
+ // it.
f->dump_int("type", d->type);
- if (d->description) {
- f->dump_string("description", d->description);
+ if (d->type & PERFCOUNTER_COUNTER) {
+ f->dump_string("metric_type", "counter");
} else {
- f->dump_string("description", "");
+ f->dump_string("metric_type", "gauge");
}
+ if (d->type & PERFCOUNTER_LONGRUNAVG) {
+ if (d->type & PERFCOUNTER_TIME) {
+ f->dump_string("value_type", "real-integer-pair");
+ } else {
+ f->dump_string("value_type", "integer-integer-pair");
+ }
+ } else if (d->type & PERFCOUNTER_HISTOGRAM) {
+ if (d->type & PERFCOUNTER_TIME) {
+ f->dump_string("value_type", "real-2d-histogram");
+ } else {
+ f->dump_string("value_type", "integer-2d-histogram");
+ }
+ } else {
+ if (d->type & PERFCOUNTER_TIME) {
+ f->dump_string("value_type", "real");
+ } else {
+ f->dump_string("value_type", "integer");
+ }
+ }
+
+ f->dump_string("description", d->description ? d->description : "");
if (d->nick != NULL) {
f->dump_string("nick", d->nick);
} else {
{
PerfCounters::perf_counter_data_vec_t::const_iterator d = m_perf_counters->m_data.begin();
PerfCounters::perf_counter_data_vec_t::const_iterator d_end = m_perf_counters->m_data.end();
- for (; d != d_end; ++d)
+ for (; d != d_end; ++d) {
assert(d->type != PERFCOUNTER_NONE);
+ assert(d->type & (PERFCOUNTER_U64 | PERFCOUNTER_TIME));
+ }
PerfCounters *ret = m_perf_counters;
m_perf_counters = NULL;
enum perfcounter_type_d : uint8_t
{
PERFCOUNTER_NONE = 0,
- PERFCOUNTER_TIME = 0x1,
- PERFCOUNTER_U64 = 0x2,
- PERFCOUNTER_LONGRUNAVG = 0x4,
- PERFCOUNTER_COUNTER = 0x8,
- PERFCOUNTER_HISTOGRAM = 0x10,
+ PERFCOUNTER_TIME = 0x1, // float (measuring seconds)
+ PERFCOUNTER_U64 = 0x2, // integer (note: either TIME or U64 *must* be set)
+ PERFCOUNTER_LONGRUNAVG = 0x4, // paired counter + sum (time)
+ PERFCOUNTER_COUNTER = 0x8, // counter (vs guage)
+ PERFCOUNTER_HISTOGRAM = 0x10, // histogram (vector) of values
};
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\":\"\",\"nick\":\"\"},"
- "\"element2\":{\"type\":1,\"description\":\"\",\"nick\":\"\"},\"element3\":{\"type\":5,\"description\":\"\",\"nick\":\"\"}}}"), msg);
+ ASSERT_EQ(sd("{\"test_perfcounter_1\":{\"element1\":{\"type\":2,\"metric_type\":\"gauge\",\"value_type\":\"integer\",\"description\":\"\",\"nick\":\"\"},\"element2\":{\"type\":1,\"metric_type\":\"gauge\",\"value_type\":\"real\",\"description\":\"\",\"nick\":\"\"},\"element3\":{\"type\":5,\"metric_type\":\"gauge\",\"value_type\":\"real-integer-pair\",\"description\":\"\",\"nick\":\"\"}}}"), msg);
coll->clear();
ASSERT_EQ("", client.do_request("{ \"prefix\": \"perf dump\", \"format\": \"json\" }", &msg));
ASSERT_EQ("{}", msg);