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, aux = nil) ⇒ Object
- #resolve_scopes!(resolved_scope) ⇒ Object
Constructor Details
Instance Method Details
#==(other) ⇒ Object
30 31 32 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 30 def ==(other) Hash[self] == Hash[other] end |
#marshal_dump ⇒ Object
22 23 24 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 22 def marshal_dump Hash[self] end |
#marshal_load(hash) ⇒ Object
26 27 28 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 26 def marshal_load(hash) self.merge!(hash) end |
#merge!(other) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 53 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, aux = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 34 def record(metric_specs, value=nil, aux=nil) Array(metric_specs).each do |metric_spec| stats = self[metric_spec] if block_given? yield stats else case value when Numeric aux ||= value stats.record_data_point(value, aux) when :apdex_s, :apdex_t, :apdex_f stats.record_apdex(value, aux) when NewRelic::Agent::Stats stats.merge!(value) end end end end |
#resolve_scopes!(resolved_scope) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/new_relic/agent/stats_engine/stats_hash.rb', line 64 def resolve_scopes!(resolved_scope) placeholder = StatsEngine::SCOPE_PLACEHOLDER.to_s each_pair do |spec, stats| spec.scope = resolved_scope if spec.scope == placeholder end end |