Module: Yabeda::DSL::ClassMethods

Defined in:
lib/yabeda/dsl/class_methods.rb

Overview

rubocop: disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#collect(&block) ⇒ Object

Define the actions that should be performed



22
23
24
# File 'lib/yabeda/dsl/class_methods.rb', line 22

def collect(&block)
  ::Yabeda.collectors.push(block)
end

#configure(&block) ⇒ Object

Block for grouping and simplifying configuration of related metrics



16
17
18
19
# File 'lib/yabeda/dsl/class_methods.rb', line 16

def configure(&block)
  class_exec(&block)
  @group = nil
end

#counter(*args, **kwargs, &block) ⇒ Object

Register a growing-only counter



39
40
41
42
# File 'lib/yabeda/dsl/class_methods.rb', line 39

def counter(*args, **kwargs, &block)
  metric = MetricBuilder.new(Counter).build(args, kwargs, @group, &block)
  register_metric(metric)
end

#default_tag(name, value) ⇒ Object

Add default tag for all metric

Parameters:

  • name (Symbol)

    Name of default tag

  • value (String)

    Value of default tag



60
61
62
# File 'lib/yabeda/dsl/class_methods.rb', line 60

def default_tag(name, value)
  ::Yabeda.default_tags[name] = value
end

#gauge(*args, **kwargs, &block) ⇒ Object

Register a gauge



45
46
47
48
# File 'lib/yabeda/dsl/class_methods.rb', line 45

def gauge(*args, **kwargs, &block)
  metric = MetricBuilder.new(Gauge).build(args, kwargs, @group, &block)
  register_metric(metric)
end

#group(group_name) ⇒ Object

Specify metric category or group for all consecutive metrics in this configure block. On most adapters it is only adds prefix to the metric name but on some (like NewRelic) it is treated individually and has a special meaning.



30
31
32
33
34
35
36
# File 'lib/yabeda/dsl/class_methods.rb', line 30

def group(group_name)
  @group = group_name
  return unless block_given?

  yield
  @group = nil
end

#histogram(*args, **kwargs, &block) ⇒ Object

Register a histogram



51
52
53
54
# File 'lib/yabeda/dsl/class_methods.rb', line 51

def histogram(*args, **kwargs, &block)
  metric = MetricBuilder.new(Histogram).build(args, kwargs, @group, &block)
  register_metric(metric)
end