Class: Harness::Measurement

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

Direct Known Subclasses

Counter, Timer

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



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

def name
  @name
end

#rateObject

Returns the value of attribute rate

Returns:

  • (Object)

    the current value of rate



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

def rate
  @rate
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



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

def value
  @value
end

Class Method Details

.from_event(event) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/harness.rb', line 11

def self.from_event(event)
  payload = event.payload
  value = payload.fetch name.split('::').last.downcase.to_sym

  case value
  when true
    new event.name
  when Fixnum
    new event.name, value
  when String
    new value
  when Hash
    new(value[:name] || event.name, value[:value], value[:rate])
  end
end

Instance Method Details

#sample_rateObject



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

def sample_rate
  rate.nil? ? 1 : rate
end