Class: Metrics::Grouping
- Inherits:
-
Object
- Object
- Metrics::Grouping
- Includes:
- StatsdApi
- Defined in:
- lib/metrics/grouping.rb
Overview
Public: Starts a new Grouping context, which allows for multiple instruments to output on a single line.
Instance Attribute Summary collapse
-
#instrumenters ⇒ Object
readonly
Returns the value of attribute instrumenters.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #group(nested_namespace = nil, *args, &block) ⇒ Object
- #increment(metric) ⇒ Object
-
#initialize(namespace = nil, options = {}, &block) ⇒ Grouping
constructor
A new instance of Grouping.
- #instrument(metric, *args, &block) ⇒ Object
Methods included from StatsdApi
#count, #decrement, #gauge, #histogram, #time, #timing
Constructor Details
#initialize(namespace = nil, options = {}, &block) ⇒ Grouping
13 14 15 16 17 18 |
# File 'lib/metrics/grouping.rb', line 13 def initialize(namespace = nil, = {}, &block) @instrumenters = [] @namespace = namespace = block.call(self) end |
Instance Attribute Details
#instrumenters ⇒ Object (readonly)
Returns the value of attribute instrumenters.
7 8 9 |
# File 'lib/metrics/grouping.rb', line 7 def instrumenters @instrumenters end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/metrics/grouping.rb', line 7 def namespace @namespace end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/metrics/grouping.rb', line 7 def end |
Class Method Details
.instrument(namespace = nil, options = {}, &block) ⇒ Object
9 10 11 |
# File 'lib/metrics/grouping.rb', line 9 def self.instrument(namespace = nil, = {}, &block) new(namespace, , &block).instrumenters end |
Instance Method Details
#group(nested_namespace = nil, *args, &block) ⇒ Object
29 30 31 32 |
# File 'lib/metrics/grouping.rb', line 29 def group(nested_namespace = nil, *args, &block) ns = nested_namespace ? "#{namespace}.#{nested_namespace}" : namespace instrumenters.push(*Grouping.instrument(ns, *(args), &block)) end |
#increment(metric) ⇒ Object
20 21 22 |
# File 'lib/metrics/grouping.rb', line 20 def increment(metric) super(metric, ) end |
#instrument(metric, *args, &block) ⇒ Object
24 25 26 27 |
# File 'lib/metrics/grouping.rb', line 24 def instrument(metric, *args, &block) metric = "#{namespace}.#{metric}" if namespace instrumenters.push(Instrumenter.instrument(metric, *(args), &block)) end |