Sha256: 85aad67a1f96976dc0272b009b55a544c781f8f26b7b883093f1e5dece8ea653
Contents?: true
Size: 1010 Bytes
Versions: 27
Compression:
Stored size: 1010 Bytes
Contents
require 'rollbar/util' require 'rollbar/truncation/mixin' module Rollbar module Truncation class StringsStrategy include ::Rollbar::Truncation::Mixin STRING_THRESHOLDS = [1024, 512, 256, 128].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| # Rollbar::Util.truncate will operate on characters, not bytes, # so use value.length, not bytesize. if value.is_a?(String) && value.length > threshold Rollbar::Util.truncate(value, threshold) else value end end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems