class ElasticAPM::Transport::Filters::HashSanitizer

@api private

Constants

FILTERED

Attributes

key_patterns[RW]

Public Class Methods

new(key_patterns:) click to toggle source
# File lib/elastic_apm/transport/filters/hash_sanitizer.rb, line 29
def initialize(key_patterns:)
  @key_patterns = key_patterns
end

Public Instance Methods

filter_key?(key) click to toggle source
# File lib/elastic_apm/transport/filters/hash_sanitizer.rb, line 53
def filter_key?(key)
  @key_patterns.any? { |regex| regex.match(key) }
end
strip_from(obj) click to toggle source
# File lib/elastic_apm/transport/filters/hash_sanitizer.rb, line 35
def strip_from(obj)
  strip_from!(Util::DeepDup.dup(obj))
end
strip_from!(obj) click to toggle source
# File lib/elastic_apm/transport/filters/hash_sanitizer.rb, line 39
def strip_from!(obj)
  return unless obj.is_a?(Hash)

  obj.each_pair do |k, v|
    case v
    when Hash
      strip_from!(v)
    else
      next unless filter_key?(k)
      obj[k] = FILTERED
    end
  end
end