Sha256: 75e037a51e10e83a0ae3b628a8b73cf0e0b5e1cf7a7e477f503d39a495ddf17a

Contents?: true

Size: 987 Bytes

Versions: 1

Compression:

Stored size: 987 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

1 entries across 1 versions & 1 rubygems

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