Module agora.stats.CollectorRegistry
Contains a collection of prometheus stat collectors that acts as an interface between the response handler, and stat collectors from every individual metric and label set.
Example
Test collection from a single delegate
auto stats = new ExampleStats();
auto registry = new CollectorRegistry([&stats .collectDg1]);
stats .setTestStats(Statistics(3600, 347, 3.14, 6.023, 0.43));
assert(registry .collect() .startsWith(
"up_time_s {id=\"123.034\"} 3600\ncount {id=\"123.034\"} 347\n" ~
"ratio {id=\"123.034\"} 3.14\nfraction {id=\"123.034\"} 6.023\n" ~
"very_real {id=\"123.034\"} 0.43\n"));
Example
Test collection from more than one delegates
auto stats = new ExampleStats();
auto registry = new CollectorRegistry([&stats .collectDg1]);
registry .addCollector(&stats .collectDg2);
stats .setTestStats(Statistics(3600, 347, 3.14, 6.023, 0.43));
stats .setTestLabels(Labels(1_235_813, "ocean", 3.14159));
assert(registry .collect() .startsWith(
"up_time_s {id=\"123.034\"} 3600\ncount {id=\"123.034\"} 347\n" ~
"ratio {id=\"123.034\"} 3.14\nfraction {id=\"123.034\"} 6.023\n" ~
"very_real {id=\"123.034\"} 0.43\n" ~
"up_time_s {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 3600\n" ~
"count {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 347\n" ~
"ratio {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 3.14\n" ~
"fraction {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 6.023\n" ~
"very_real {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 0.43\n"));
Example
Test that the collections are not accumulated upon more than one call to
the collect
method.
auto stats = new ExampleStats();
auto registry = new CollectorRegistry([&stats .collectDg2]);
stats .setTestStats(Statistics(3600, 347, 3.14, 6.023, 0.43));
stats .setTestLabels(Labels(1_235_813, "ocean", 3.14159));
auto collected = registry .collect();
// Update the stats
stats .setTestStats(Statistics(4200, 257, 2.345, 1.098, 0.56));
// A 2nd call to `collect` should return the updated stats, without the
// previous values anywhere in it.
assert(registry .collect(),
"up_time_s {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 4200\n" ~
"count {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 257\n" ~
"ratio {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 2.345\n" ~
"fraction {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 1.098\n" ~
"very_real {id=\"1235813\",job=\"ocean\",perf=\"3.14159\"} 0.56\n");
Classes
Name | Description |
---|---|
CollectorRegistry
|