&(metric_family_t){
.name = "unit.tests",
.help = "Example gauge metric",
+ .unit = "1",
.type = METRIC_TYPE_GAUGE,
},
&(metric_family_t){
.name = "unit.test.count",
.help = "Example counter metric",
+ .unit = "{test}",
.type = METRIC_TYPE_COUNTER,
},
};
"{\"resourceMetrics\":[{\"resource\":{\"attributes\":[{\"key\":\"service."
"name\",\"value\":{\"stringValue\":\"unit "
"test\"}}]},\"scopeMetrics\":[{\"scope\":{\"name\":\"collectd\","
- "\"version\":\"" PACKAGE_VERSION "\"},\"metrics\":[{\"name\":\"unit."
- "test.count\",\"description\":\"Example counter "
+ "\"version\":\"" PACKAGE_VERSION
+ "\"},\"metrics\":[{\"name\":\"unit.test.count\",\"unit\":\"{test}\","
+ "\"description\":\"Example counter "
"metric\",\"sum\":{\"dataPoints\":[{\"attributes\":[{\"key\":\"metric."
"label\",\"value\":{\"stringValue\":\"bar\"}}],\"timeUnixNano\":0,"
"\"asInt\":31337}],\"aggregationTemporality\":\"2\",\"isMonotonic\":true}"
- "},{\"name\":\"unit.tests\",\"description\":\"Example gauge "
+ "},{\"name\":\"unit.tests\",\"unit\":\"1\",\"description\":\"Example "
+ "gauge "
"metric\",\"gauge\":{\"dataPoints\":[{\"attributes\":[{\"key\":\"metric."
"label\",\"value\":{\"stringValue\":\"test "
"label\"}}],\"timeUnixNano\":0,\"asDouble\":42.0}]}}]}]}]}",
CHECK(json_add_string(g, "name"));
CHECK(json_add_string(g, fam->name));
- // TODO(octo): populate the "unit" field.
- // CHECK(json_add_string(g, "unit"));
- // CHECK(json_add_string(g, "1"));
+ if (fam->unit != NULL) {
+ CHECK(json_add_string(g, "unit"));
+ CHECK(json_add_string(g, fam->unit));
+ }
if (fam->help != NULL) {
CHECK(json_add_string(g, "description"));