Class: Promenade::Prometheus::Options
- Inherits:
-
Object
- Object
- Promenade::Prometheus::Options
- Defined in:
- lib/promenade/prometheus.rb
Constant Summary collapse
- BUCKET_PRESETS =
{ network: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10].freeze, memory: (0..10).map { |i| 128 * (2**i) }, }.freeze
Instance Method Summary collapse
- #args(type) ⇒ Object
- #base_labels(labels) ⇒ Object
- #buckets(buckets) ⇒ Object
- #doc(str) ⇒ Object
- #evaluate(&block) ⇒ Object
-
#initialize ⇒ Options
constructor
A new instance of Options.
- #multiprocess_mode(mode) ⇒ Object
Constructor Details
#initialize ⇒ Options
Returns a new instance of Options.
41 42 43 44 45 46 |
# File 'lib/promenade/prometheus.rb', line 41 def initialize @buckets = BUCKET_PRESETS[:network] @base_labels = {} @doc = nil @multiprocess_mode = :all end |
Instance Method Details
#args(type) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/promenade/prometheus.rb', line 69 def args(type) case type when :gauge [@doc, @base_labels, @multiprocess_mode] when :histogram [@doc, @base_labels, @buckets] when :counter, :summary [@doc, @base_labels] else fail "Unsupported metric type: #{type}" end end |
#base_labels(labels) ⇒ Object
52 53 54 |
# File 'lib/promenade/prometheus.rb', line 52 def base_labels(labels) @base_labels = labels end |
#buckets(buckets) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/promenade/prometheus.rb', line 60 def buckets(buckets) if buckets.is_a?(Symbol) @buckets = BUCKET_PRESETS[buckets] fail "#{buckets} is not a valid bucket preset" if @buckets.nil? else @buckets = buckets end end |
#doc(str) ⇒ Object
48 49 50 |
# File 'lib/promenade/prometheus.rb', line 48 def doc(str) @doc = str end |
#evaluate(&block) ⇒ Object
82 83 84 85 |
# File 'lib/promenade/prometheus.rb', line 82 def evaluate(&block) instance_eval(&block) self end |
#multiprocess_mode(mode) ⇒ Object
56 57 58 |
# File 'lib/promenade/prometheus.rb', line 56 def multiprocess_mode(mode) @multiprocess_mode = mode end |