Module: Yabeda::DSL::ClassMethods
- Defined in:
- lib/yabeda/dsl/class_methods.rb
Overview
rubocop: disable Style/Documentation
Instance Method Summary collapse
-
#collect(&block) ⇒ Object
Define the actions that should be performed.
-
#configure(&block) ⇒ Object
Block for grouping and simplifying configuration of related metrics.
-
#counter(*args, **kwargs, &block) ⇒ Object
Register a growing-only counter.
-
#default_tag(name, value) ⇒ Object
Add default tag for all metric.
-
#gauge(*args, **kwargs, &block) ⇒ Object
Register a gauge.
-
#group(group_name) ⇒ Object
Specify metric category or group for all consecutive metrics in this
configure
block. -
#histogram(*args, **kwargs, &block) ⇒ Object
Register a histogram.
-
#temporary_tags ⇒ Object
private
Get tags set by
with_tags
. -
#with_tags(**tags) ⇒ Object
Redefine default tags for a limited amount of time.
Instance Method Details
#collect(&block) ⇒ Object
Define the actions that should be performed
23 24 25 |
# File 'lib/yabeda/dsl/class_methods.rb', line 23 def collect(&block) ::Yabeda.collectors.push(block) end |
#configure(&block) ⇒ Object
Block for grouping and simplifying configuration of related metrics
16 17 18 19 20 |
# File 'lib/yabeda/dsl/class_methods.rb', line 16 def configure(&block) Yabeda.configurators.push([@group, block]) class_exec(&block) if Yabeda.configured? @group = nil end |
#counter(*args, **kwargs, &block) ⇒ Object
Register a growing-only counter
40 41 42 43 |
# File 'lib/yabeda/dsl/class_methods.rb', line 40 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
61 62 63 |
# File 'lib/yabeda/dsl/class_methods.rb', line 61 def default_tag(name, value) ::Yabeda.[name] = value end |
#gauge(*args, **kwargs, &block) ⇒ Object
Register a gauge
46 47 48 49 |
# File 'lib/yabeda/dsl/class_methods.rb', line 46 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.
31 32 33 34 35 36 37 |
# File 'lib/yabeda/dsl/class_methods.rb', line 31 def group(group_name) @group = group_name return unless block_given? yield @group = nil end |
#histogram(*args, **kwargs, &block) ⇒ Object
Register a histogram
52 53 54 55 |
# File 'lib/yabeda/dsl/class_methods.rb', line 52 def histogram(*args, **kwargs, &block) metric = MetricBuilder.new(Histogram).build(args, kwargs, @group, &block) register_metric(metric) end |
#temporary_tags ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get tags set by with_tags
77 78 79 |
# File 'lib/yabeda/dsl/class_methods.rb', line 77 def Thread.current[:yabeda_temporary_tags] || {} end |
#with_tags(**tags) ⇒ Object
Redefine default tags for a limited amount of time
67 68 69 70 71 72 |
# File 'lib/yabeda/dsl/class_methods.rb', line 67 def (**) Thread.current[:yabeda_temporary_tags] = yield ensure Thread.current[:yabeda_temporary_tags] = {} end |