Module: OneApm::CollectionHelper
- Included in:
- OneApm::Collector::ErrorCollector, DeveloperModeHelper, NoticedError, TransactionSampleBuilder
- Defined in:
- lib/one_apm/support/collection_helper.rb
Constant Summary collapse
- OA_DEFAULT_TRUNCATION_SIZE =
16 * 1024
- OA_DEFAULT_ARRAY_TRUNCATION_SIZE =
128
Instance Method Summary collapse
-
#normalize_params(params) ⇒ Object
Transform parameter hash into a hash whose values are strictly strings.
-
#strip_oa_from_backtrace(backtrace) ⇒ Object
Return an array of strings (backtrace), cleaned up for readability Return nil if there is no backtrace.
Instance Method Details
#normalize_params(params) ⇒ Object
Transform parameter hash into a hash whose values are strictly strings
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/one_apm/support/collection_helper.rb', line 11 def normalize_params(params) case params when Hash # optimize for empty hash since that is often what this is called with. return params if params.empty? new_params = {} params.each do | key, value | new_params[truncate(normalize_params(key),64)] = normalize_params(value) end new_params when Symbol, FalseClass, TrueClass, nil params when Numeric truncate(params.to_s) when String truncate(params) when Array params.first(OA_DEFAULT_ARRAY_TRUNCATION_SIZE).map{|item| normalize_params(item)} else truncate(flatten(params)) end end |
#strip_oa_from_backtrace(backtrace) ⇒ Object
Return an array of strings (backtrace), cleaned up for readability Return nil if there is no backtrace
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/one_apm/support/collection_helper.rb', line 37 def strip_oa_from_backtrace(backtrace) if backtrace && !Manager.config[:disable_backtrace_cleanup] # this is for 1.9.1, where strings no longer have Enumerable backtrace = backtrace.split("\n") if String === backtrace backtrace = backtrace.map(&:to_s) backtrace = backtrace.reject do |line| line.include?(OneApm::Probe.oneapm_root) or line =~ /^oneapm_rpm\s/ end # rename methods back to their original state backtrace = backtrace.collect {|line| line.gsub(/_without_(oneapm|trace)/, "")} end backtrace end |