Class: NewRelic::Agent::StatsHash
- Inherits:
-
Hash
- Object
- Hash
- NewRelic::Agent::StatsHash
- Defined in:
- lib/new_relic/agent/stats_engine/stats_hash.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize ⇒ StatsHash
constructor
A new instance of StatsHash.
- #marshal_dump ⇒ Object
- #marshal_load(hash) ⇒ Object
- #merge!(other) ⇒ Object
- #record(metric_specs, value = nil) ⇒ Object
Constructor Details
Instance Method Details
#==(other) ⇒ Object
26 27 28 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 26 def ==(other) Hash[self] == Hash[other] end |
#marshal_dump ⇒ Object
18 19 20 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 18 def marshal_dump Hash[self] end |
#marshal_load(hash) ⇒ Object
22 23 24 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 22 def marshal_load(hash) self.merge!(hash) end |
#merge!(other) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 46 def merge!(other) other.each do |key,val| if self.has_key?(key) self[key].merge!(val) else self[key] = val end end self end |
#record(metric_specs, value = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 30 def record(metric_specs, value=nil) Array(metric_specs).each do |metric_spec| stats = self[metric_spec] if block_given? yield stats else case value when Numeric stats.record_data_point(value) when NewRelic::Agent::Stats stats.merge!(value) end end end end |