Sha256: 5e9f1fa90c5a10cf7566e901af7e6a12f7c1133a05a23e5abacafaa67922dfa0

Contents?: true

Size: 956 Bytes

Versions: 6

Compression:

Stored size: 956 Bytes

Contents

require 'rollbar/truncation/mixin'
require 'rollbar/util'

module Rollbar
  module Truncation
    class MinBodyStrategy
      include ::Rollbar::Truncation::Mixin

      def self.call(payload)
        new.call(payload)
      end

      def call(payload)
        new_payload = Rollbar::Util.deep_copy(payload)
        body = new_payload['data']['body']

        if body['trace_chain']
          body['trace_chain'] = body['trace_chain'].map do |trace_data|
            truncate_trace_data(trace_data)
          end
        elsif body['trace']
          body['trace'] = truncate_trace_data(body['trace'])
        end


        dump(new_payload)
      end

      def truncate_trace_data(trace_data)
        trace_data['exception'].delete('description')
        trace_data['exception']['message'] = trace_data['exception']['message'][0, 255]
        trace_data['frames'] = select_frames(trace_data['frames'], 1)

        trace_data
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rollbar-2.14.1 lib/rollbar/truncation/min_body_strategy.rb
rollbar-2.14.0 lib/rollbar/truncation/min_body_strategy.rb
rollbar-2.13.3 lib/rollbar/truncation/min_body_strategy.rb
rollbar-2.13.2 lib/rollbar/truncation/min_body_strategy.rb
rollbar-2.13.1 lib/rollbar/truncation/min_body_strategy.rb
rollbar-2.13.0 lib/rollbar/truncation/min_body_strategy.rb