Class: ElasticAPM::Transport::Filters::HashSanitizer Private
- Inherits:
-
Object
- Object
- ElasticAPM::Transport::Filters::HashSanitizer
- Defined in:
- lib/elastic_apm/transport/filters/hash_sanitizer.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- FILTERED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'[FILTERED]'
Instance Attribute Summary collapse
- #key_patterns ⇒ Object private
Instance Method Summary collapse
- #filter_key?(key) ⇒ Boolean private
-
#initialize(key_patterns:) ⇒ HashSanitizer
constructor
private
A new instance of HashSanitizer.
- #strip_from(obj) ⇒ Object private
- #strip_from!(obj) ⇒ Object private
Constructor Details
#initialize(key_patterns:) ⇒ HashSanitizer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HashSanitizer.
29 30 31 |
# File 'lib/elastic_apm/transport/filters/hash_sanitizer.rb', line 29 def initialize(key_patterns:) @key_patterns = key_patterns end |
Instance Attribute Details
#key_patterns ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/elastic_apm/transport/filters/hash_sanitizer.rb', line 33 def key_patterns @key_patterns end |
Instance Method Details
#filter_key?(key) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 |
# 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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 |