Sha256: e3641f652a4f3c4dd839cd4dbff8ce3f3565fc058b1b68dfc456c41cd41ac3fe

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 Bytes

Contents

require 'rollbar/truncation/mixin'

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

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

      def call(payload)
        new_payload = payload.clone
        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
        else
          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

1 entries across 1 versions & 1 rubygems

Version Path
rollbar-1.2.11 lib/rollbar/truncation/min_body_strategy.rb