Class: Librato::LogReporter::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/librato/logreporter/group.rb

Overview

Encapsulates state for grouping operations

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Group

Returns a new instance of Group.



8
9
10
11
# File 'lib/librato/logreporter/group.rb', line 8

def initialize(options={})
  @collector = options[:collector]
  @prefix = "#{options[:prefix]}."
end

Instance Method Details

#group(prefix) {|self.class.new(collector: @collector, prefix: prefix)| ... } ⇒ Object

Yields:

  • (self.class.new(collector: @collector, prefix: prefix))


13
14
15
16
# File 'lib/librato/logreporter/group.rb', line 13

def group(prefix)
  prefix = apply_prefix(prefix)
  yield self.class.new(collector: @collector, prefix: prefix)
end

#increment(counter, options = {}) ⇒ Object



18
19
20
21
# File 'lib/librato/logreporter/group.rb', line 18

def increment(counter, options={})
  counter = apply_prefix(counter)
  @collector.increment counter, options
end

#measure(*args, &block) ⇒ Object Also known as: timing



23
24
25
26
# File 'lib/librato/logreporter/group.rb', line 23

def measure(*args, &block)
  args[0] = apply_prefix(args[0])
  @collector.measure(*args, &block)
end