Sha256: 674cd215587aeebe72e50749ae823b5a0c37b459c20441c53cbf24caca340937
Contents?: true
Size: 958 Bytes
Versions: 2
Compression:
Stored size: 958 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, 64].freeze def self.call(payload) new.call(payload) end def call(payload) result = nil new_payload = Rollbar::Util.deep_copy(payload) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rollbar-2.20.0 | lib/rollbar/truncation/strings_strategy.rb |
rollbar-2.19.4 | lib/rollbar/truncation/strings_strategy.rb |