Sha256: fd0d4028e1a4b70f7f862dad9f72876ee2889bb13d7fad7a2b6a0562594973d3
Contents?: true
Size: 886 Bytes
Versions: 5
Compression:
Stored size: 886 Bytes
Contents
require 'rollbar/util' require 'rollbar/truncation/mixin' module Rollbar module Truncation class StringsStrategy include ::Rollbar::Truncation::Mixin STRING_THRESHOLDS = [1024, 512, 256].freeze def self.call(payload) new.call(payload) end def call(payload) result = nil STRING_THRESHOLDS.each do |threshold| truncate_proc = truncate_strings_proc(threshold) ::Rollbar::Util.iterate_and_update(payload, truncate_proc) result = dump(payload) break unless truncate?(result) end result end def truncate_strings_proc(threshold) proc do |value| if value.is_a?(String) && value.bytesize > threshold Rollbar::Util.truncate(value, threshold) else value end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems