aboutsummaryrefslogtreecommitdiff
path: root/examples/test_histo.rb
diff options
context:
space:
mode:
authorNat Lasseter <nat.lasseter@york.ac.uk>2020-11-16 12:25:42 +0000
committerNat Lasseter <nat.lasseter@york.ac.uk>2020-11-16 12:25:42 +0000
commit96b8a92fc11d094eedc24bf9b3f76a230d654416 (patch)
tree4788565ba5ce65cd40d0aa9f967eb44c4d63c665 /examples/test_histo.rb
parent622a1770df1baa13c02f155cde3301306c8f8be0 (diff)
Better examples
Diffstat (limited to 'examples/test_histo.rb')
-rw-r--r--examples/test_histo.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/test_histo.rb b/examples/test_histo.rb
new file mode 100644
index 0000000..ed3fb01
--- /dev/null
+++ b/examples/test_histo.rb
@@ -0,0 +1,41 @@
+class TestHisto
+ def initialize(collector, config)
+ @collector = collector
+ @config = config
+ end
+
+ def raid
+ # Clean up any previously reported metrics
+ # to prevent stale labelsets
+ @collector.redact!("histo")
+ @collector.redact!("summ")
+
+ # Report new metrics
+ @collector.report!(
+ "histo",
+ {
+ buckets: {
+ 0.5 => 1,
+ 1 => 2
+ },
+ count: 3,
+ sum: 3
+ },
+ help: "A histogram over the data [0.25, 0.75, 2]",
+ type: "histogram"
+ )
+ @collector.report!(
+ "summ",
+ {
+ quantiles: {
+ 0.5 => 5,
+ 0.95 => 9.5
+ },
+ count: 21,
+ sum: 105
+ },
+ help: "A summary of data (0..10).step(0.5)",
+ type: "summary"
+ )
+ end
+end