Skip to content

Commit

Permalink
Simplified stacktrace trimming to require less conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec committed Mar 27, 2018
1 parent e595c3c commit 33d60bb
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/bugsnag/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ def self.trim_stacktrace_code(payload, threshold)
return payload unless payload.is_a?(Hash) and payload[:events].respond_to?(:map)
payload[:events].map do |event|
event[:exceptions].map do |exception|
initial_size = get_payload_length(exception[:stacktrace])
saved = 0
exception[:stacktrace].reverse.each do |trace|
break unless (initial_size - get_payload_length(exception[:stacktrace])) < threshold
break unless saved < threshold
saved += get_payload_length(trace[:code])
trace.delete(:code)
end
end
Expand All @@ -105,9 +106,10 @@ def self.trim_stacktrace_functions(payload, threshold)
return payload unless payload.is_a?(Hash) and payload[:events].respond_to?(:map)
payload[:events].map do |event|
event[:exceptions].map do |exception|
initial_size = get_payload_length(exception[:stacktrace])
exception[:stacktrace].each do |i|
break unless (initial_size - get_payload_length(exception[:stacktrace])) < threshold
saved = 0
exception[:stacktrace].each do
break unless saved < threshold
saved += get_payload_length(exception[:stacktrace].last)
exception[:stacktrace].pop
end
end
Expand Down

0 comments on commit 33d60bb

Please sign in to comment.