File: example.rb

package info (click to toggle)
ruby-prometheus-client-mmap 1.2.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 700 kB
  • sloc: ruby: 3,149; sh: 54; makefile: 21
file content (28 lines) | stat: -rw-r--r-- 936 bytes parent folder | download
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
$LOAD_PATH.unshift("./lib")

require 'prometheus/client'
require 'prometheus/client/formats/text.rb'
require 'pp'

prometheus = Prometheus::Client.registry

counter = Prometheus::Client::Counter.new(:mycounter, 'Example counter')
gauge = Prometheus::Client::Gauge.new(:mygauge, 'Example gauge', {}, :livesum)
histogram = Prometheus::Client::Histogram.new(:myhistogram, 'Example histogram', {}, [0, 1, 2])
prometheus.register(counter)
prometheus.register(gauge)
prometheus.register(histogram)

counter.increment({'foo': 'bar'}, 2)
counter.increment({'foo': 'biz'}, 4)
gauge.set({'foo': 'bar'}, 3)
gauge.set({'foo': 'biz'}, 3)
gauge.decrement({'foo': 'bar'}, 1)
histogram.observe({'foo': 'bar'}, 0.5)
histogram.observe({'foo': 'biz'}, 0.5)
histogram.observe({'foo': 'bar'}, 1.5)
histogram.observe({'foo': 'biz'}, 2)

#puts Prometheus::Client::Formats::Text.marshal(prometheus)

puts Prometheus::Client::Formats::Text.marshal_multiprocess