Sha256: e374fb47f02b111740703eb6ad52f0371e5f114124b837cc9cb583dec07d611a

Contents?: true

Size: 1000 Bytes

Versions: 3

Compression:

Stored size: 1000 Bytes

Contents

require 'rollbar/truncation/mixin'

module Rollbar
  module Truncation
    class FramesStrategy
      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']
          truncate_trace_chain(body)
        else
          truncate_trace(body)
        end

        dump(new_payload)
      end

      def truncate_trace(body)
        trace_data = body['trace']
        frames = trace_data['frames']
        trace_data['frames'] = select_frames(frames)

        body['trace']['frames'] = select_frames(body['trace']['frames'])
      end

      def truncate_trace_chain(body)
        chain = body['trace_chain']

        body['trace_chain'] = chain.map do |trace_data|
          frames = trace_data['frames']
          trace_data['frames'] = select_frames(frames)
          trace_data
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rollbar-1.3.0 lib/rollbar/truncation/frames_strategy.rb
rollbar-1.2.13 lib/rollbar/truncation/frames_strategy.rb
rollbar-1.2.12 lib/rollbar/truncation/frames_strategy.rb