Sha256: 2d8247219b6f2f714fb92e7e37f9f9739deebdc2e0e186994372e3ca1a185e4a

Contents?: true

Size: 759 Bytes

Versions: 2

Compression:

Stored size: 759 Bytes

Contents

require 'rollbar/util'
require 'rollbar/truncation/mixin'
require 'rollbar/truncation/raw_strategy'
require 'rollbar/truncation/frames_strategy'
require 'rollbar/truncation/strings_strategy'
require 'rollbar/truncation/min_body_strategy'

module Rollbar
  module Truncation
    extend ::Rollbar::Truncation::Mixin

    MAX_PAYLOAD_SIZE = 512 * 1024 # 512kb
    STRATEGIES = [RawStrategy,
                  FramesStrategy,
                  StringsStrategy,
                  MinBodyStrategy].freeze

    def self.truncate(payload, attempts = [])
      result = nil

      STRATEGIES.each do |strategy|
        result = strategy.call(payload)
        attempts << result.bytesize
        break unless truncate?(result)
      end

      result
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rollbar-2.20.0 lib/rollbar/truncation.rb
rollbar-2.19.4 lib/rollbar/truncation.rb