Class: Librato::Collector

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/librato/collector.rb,
lib/librato/collector/group.rb,
lib/librato/collector/aggregator.rb,
lib/librato/collector/exceptions.rb,
lib/librato/collector/counter_cache.rb

Overview

collects and stores measurement values over time so they can be reported periodically to the Metrics service

Defined Under Namespace

Classes: Aggregator, CounterCache, Group, InvalidPercentile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Collector

Returns a new instance of Collector.



15
16
17
# File 'lib/librato/collector.rb', line 15

def initialize(options={})
  @tags = options[:tags]
end

Instance Attribute Details

#tagsObject (readonly)

Returns the value of attribute tags.



13
14
15
# File 'lib/librato/collector.rb', line 13

def tags
  @tags
end

Instance Method Details

#aggregateObject

access to internal aggregator object



20
21
22
# File 'lib/librato/collector.rb', line 20

def aggregate
  @aggregator_cache ||= Aggregator.new(prefix: @prefix, default_tags: @tags)
end

#countersObject

access to internal counters object



25
26
27
# File 'lib/librato/collector.rb', line 25

def counters
  @counter_cache ||= CounterCache.new(default_tags: @tags)
end

#delete_allObject Also known as: clear

remove any accumulated but unsent metrics



30
31
32
33
# File 'lib/librato/collector.rb', line 30

def delete_all
  aggregate.delete_all
  counters.delete_all
end

#group(prefix) {|group| ... } ⇒ Object

Yields:



36
37
38
39
# File 'lib/librato/collector.rb', line 36

def group(prefix)
  group = Group.new(self, prefix)
  yield group
end

#prefixObject



47
48
49
# File 'lib/librato/collector.rb', line 47

def prefix
  @prefix
end

#prefix=(new_prefix) ⇒ Object

update prefix



42
43
44
45
# File 'lib/librato/collector.rb', line 42

def prefix=(new_prefix)
  @prefix = new_prefix
  aggregate.prefix = @prefix
end