aboutsummaryrefslogtreecommitdiff
path: root/examples/test_histo.rb
blob: ed3fb01df4341f0e085a810c7e9e7e18f9c429cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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