Module: NewRelic::Agent::CollectionHelper

Included in:
ErrorCollector, TransactionSampleBuilder
Defined in:
lib/new_relic/agent/collection_helper.rb

Instance Method Summary collapse

Instance Method Details

#normalize_params(params) ⇒ Object

Transform parameter hash into a hash whose values are strictly strings



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/new_relic/agent/collection_helper.rb', line 4

def normalize_params(params)
  case params
    when Symbol, FalseClass, TrueClass, nil
      params
    when Numeric
      truncate(params.to_s)
    when String
      truncate(params)
    when Hash
      new_params = {}
      params.each do | key, value |
        new_params[truncate(normalize_params(key),32)] = normalize_params(value)
      end
      new_params
    when Array
      params.first(20).map{|item| normalize_params(item)}
  else
    truncate(flatten(params))
  end
end

#strip_nr_from_backtrace(backtrace) ⇒ Object

Return an array of strings (backtrace), cleaned up for readability Return nil if there is no backtrace



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/new_relic/agent/collection_helper.rb', line 28

def strip_nr_from_backtrace(backtrace)
  if backtrace
    # this is for 1.9.1, where strings no longer have Enumerable
    backtrace = backtrace.split("\n") if String === backtrace
    # strip newrelic from the trace
    backtrace = backtrace.reject {|line| line =~ /new_relic\/agent\// }
    # rename methods back to their original state
    backtrace = backtrace.collect {|line| line.gsub(/_without_(newrelic|trace)/, "")}
  end
  backtrace
end