class Metrics::Grouping
Public: Starts a new Grouping
context, which allows for multiple instruments to output on a single line.
Attributes
instrumenters[R]
namespace[R]
options[R]
Public Class Methods
instrument(namespace = nil, options = {}, &block)
click to toggle source
# File lib/metrics/grouping.rb, line 9 def self.instrument(namespace = nil, options = {}, &block) new(namespace, options, &block).instrumenters end
new(namespace = nil, options = {}, &block)
click to toggle source
# File lib/metrics/grouping.rb, line 13 def initialize(namespace = nil, options = {}, &block) @instrumenters = [] @namespace = namespace @options = options block.call(self) end
Public Instance Methods
group(nested_namespace = nil, *args, &block)
click to toggle source
# 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, *merge_options(args), &block)) end
increment(metric)
click to toggle source
Calls superclass method
Metrics::StatsdApi#increment
# File lib/metrics/grouping.rb, line 20 def increment(metric) super(metric, options) end
instrument(metric, *args, &block)
click to toggle source
# File lib/metrics/grouping.rb, line 24 def instrument(metric, *args, &block) metric = "#{namespace}.#{metric}" if namespace instrumenters.push(Instrumenter.instrument(metric, *merge_options(args), &block)) end
Private Instance Methods
extract_options!(options)
click to toggle source
# File lib/metrics/grouping.rb, line 42 def extract_options!(options) Metrics::Helpers.extract_options!(options) end
merge_options(args)
click to toggle source
# File lib/metrics/grouping.rb, line 36 def merge_options(args) opts = extract_options!(args) args << options.merge(opts) args end