Class: Nosey::Probe::Set

Inherits:
Object
  • Object
show all
Defined in:
lib/nosey/probe.rb

Overview

Contains a collection of probes that calculate velocities, counts, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) {|_self| ... } ⇒ Set

Returns a new instance of Set.

Yields:

  • (_self)

Yield Parameters:



100
101
102
103
104
# File 'lib/nosey/probe.rb', line 100

def initialize(name)
  @name = name
  yield self if block_given?
  self
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



98
99
100
# File 'lib/nosey/probe.rb', line 98

def name
  @name
end

Instance Method Details

#avg(key, value) ⇒ Object

Sample a number and get a sum/avg/count/min/max



117
118
119
# File 'lib/nosey/probe.rb', line 117

def avg(key,val)
  ensure_probe(Probe::Average, key).sample(val)
end

#decrement(key, by = 1) ⇒ Object

Decrement a counter probe



112
113
114
# File 'lib/nosey/probe.rb', line 112

def decrement(key,by=1)
  ensure_probe(Probe::Count, key).decrement(by)
end

#increment(key, by = 1) ⇒ Object

Increment a counter probe



107
108
109
# File 'lib/nosey/probe.rb', line 107

def increment(key,by=1)
  ensure_probe(Probe::Count, key).increment(by)
end

#max(key, value) ⇒ Object



130
131
132
# File 'lib/nosey/probe.rb', line 130

def max(key,value)
  ensure_probe(Probe::Maximum, key).sample(value)
end

#min(key, value) ⇒ Object



126
127
128
# File 'lib/nosey/probe.rb', line 126

def min(key,value)
  ensure_probe(Probe::Minimum, key).sample(value)
end

#probe(key) ⇒ Object

Get a probe and do all sorts of crazy stuff to it.



148
149
150
# File 'lib/nosey/probe.rb', line 148

def probe(key)
  probes[key]
end

#probesObject

List of all the probes that are active



143
144
145
# File 'lib/nosey/probe.rb', line 143

def probes
  @probes ||= Hash.new
end

#reportObject

Generate a report with this ProbeSet



153
154
155
156
157
# File 'lib/nosey/probe.rb', line 153

def report
  Report.new do |r|
    r.probe_sets << self
  end
end

#resetObject

Reset the values in all the probes



160
161
162
# File 'lib/nosey/probe.rb', line 160

def reset
  probes.each{|_, probe| probe.reset }
end

#sum(key, value) ⇒ Object



138
139
140
# File 'lib/nosey/probe.rb', line 138

def sum(key,value)
  ensure_probe(Probe::Sum, key).sample(value)
end

#touch(key) ⇒ Object

Touch a timestamp probe



122
123
124
# File 'lib/nosey/probe.rb', line 122

def touch(key)
  ensure_probe(Probe::Touch, key).touch
end