Class: Harness::FakeCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/harness/fake_collector.rb

Defined Under Namespace

Classes: Decrement, Gauge, Increment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFakeCollector

Returns a new instance of FakeCollector.



9
10
11
# File 'lib/harness/fake_collector.rb', line 9

def initialize
  @gauges, @counters, @timers, @increments, @decrements = [], [], [], [], []
end

Instance Attribute Details

#countersObject (readonly)

Returns the value of attribute counters.



7
8
9
# File 'lib/harness/fake_collector.rb', line 7

def counters
  @counters
end

#decrementsObject (readonly)

Returns the value of attribute decrements.



7
8
9
# File 'lib/harness/fake_collector.rb', line 7

def decrements
  @decrements
end

#gaugesObject (readonly)

Returns the value of attribute gauges.



7
8
9
# File 'lib/harness/fake_collector.rb', line 7

def gauges
  @gauges
end

#incrementsObject (readonly)

Returns the value of attribute increments.



7
8
9
# File 'lib/harness/fake_collector.rb', line 7

def increments
  @increments
end

#timersObject (readonly)

Returns the value of attribute timers.



7
8
9
# File 'lib/harness/fake_collector.rb', line 7

def timers
  @timers
end

Instance Method Details

#count(*args) ⇒ Object



32
33
34
# File 'lib/harness/fake_collector.rb', line 32

def count(*args)
  counters << Harness::Counter.new(*args)
end

#decrement(*args) ⇒ Object



28
29
30
# File 'lib/harness/fake_collector.rb', line 28

def decrement(*args)
  decrements << Decrement.new(*args)
end

#gauge(*args) ⇒ Object



36
37
38
# File 'lib/harness/fake_collector.rb', line 36

def gauge(*args)
  gauges << Gauge.new(*args)
end

#increment(*args) ⇒ Object



24
25
26
# File 'lib/harness/fake_collector.rb', line 24

def increment(*args)
  increments << Increment.new(*args)
end

#time(stat, sample_rate = 1) ⇒ Object



17
18
19
20
21
22
# File 'lib/harness/fake_collector.rb', line 17

def time(stat, sample_rate = 1)
  start = Time.now
  result = yield
  timing(stat, ((Time.now - start) * 1000).round, sample_rate)
  result
end

#timing(*args) ⇒ Object



13
14
15
# File 'lib/harness/fake_collector.rb', line 13

def timing(*args)
  timers << Harness::Timer.new(*args)
end