module NewRelic::Agent::PayloadMetricMapping

Constants

SPEC_MAPPINGS

this logic was extracted from TransactionEventAggregator for reuse by the ErrorEventAggregator

Public Class Methods

append_mapped_metrics(txn_metrics, sample) click to toggle source
# File lib/new_relic/agent/payload_metric_mapping.rb, line 15
def append_mapped_metrics(txn_metrics, sample)
  if txn_metrics
    SPEC_MAPPINGS.each do |(name, extracted_values)|
      if txn_metrics.has_key?(name)
        stat = txn_metrics[name]
        extracted_values.each do |value_name, key_name|
          sample[key_name] = stat.send(value_name)
        end
      end
    end
  end
end

Private Class Methods

map_metric(metric_name, to_add={}) click to toggle source
# File lib/new_relic/agent/payload_metric_mapping.rb, line 30
def map_metric(metric_name, to_add={})
  to_add.values.each(&:freeze)

  mappings = SPEC_MAPPINGS.fetch(metric_name, {})
  mappings.merge!(to_add)

  SPEC_MAPPINGS[metric_name] = mappings
end