Module: NewRelic::Agent::StatsEngine::MetricStats::Harvest

Included in:
NewRelic::Agent::StatsEngine::MetricStats
Defined in:
lib/new_relic/agent/stats_engine/metric_stats.rb

Overview

This module was extracted from the harvest method and should be refactored

Instance Method Summary collapse

Instance Method Details

#merge_data(metric_data_hash) ⇒ Object

merge data from previous harvests into this stats engine - takes into account the case where there are new stats for that metric, and the case where there is no current data for that metric



82
83
84
85
86
87
88
89
90
91
# File 'lib/new_relic/agent/stats_engine/metric_stats.rb', line 82

def merge_data(metric_data_hash)
  metric_data_hash.each do |metric_spec, metric_data|
    new_data = lookup_stats(metric_spec.name, metric_spec.scope)
    if new_data
      new_data.merge!(metric_data.stats)
    else
      stats_hash[metric_spec] = metric_data.stats
    end
  end
end