Sha256: a378a4008ac319335f97be0802ae6d9eefda6c33bcdec74003f5cbceff0b4923
Contents?: true
Size: 923 Bytes
Versions: 49
Compression:
Stored size: 923 Bytes
Contents
require 'rollbar/util' require 'rollbar/truncation/mixin' module Rollbar module Truncation class StringsStrategy include ::Rollbar::Truncation::Mixin STRING_THRESHOLDS = [1024, 512, 256] def self.call(payload) new.call(payload) end def call(payload) result = nil new_payload = payload.clone STRING_THRESHOLDS.each do |threshold| truncate_proc = truncate_strings_proc(threshold) ::Rollbar::Util.iterate_and_update(new_payload, truncate_proc) result = dump(new_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
49 entries across 49 versions & 1 rubygems