module NewRelic::Agent::Datastores::NosqlObfuscator

Constants

ALLOWLIST
QUESTION_MARK

Public Class Methods

obfuscate_statement(source, allowlist = ALLOWLIST) click to toggle source
# File lib/new_relic/agent/datastores/nosql_obfuscator.rb, line 11
def self.obfuscate_statement(source, allowlist = ALLOWLIST)
  if source.is_a?(Hash)
    obfuscated = {}
    source.each do |key, value|
      if allowlist.include?(key)
        obfuscated[key] = value
      else
        obfuscated[key] = obfuscate_value(value, allowlist)
      end
    end
    obfuscated
  else
    obfuscate_value(source, allowlist)
  end
end
obfuscate_value(value, allowlist = ALLOWLIST) click to toggle source
# File lib/new_relic/agent/datastores/nosql_obfuscator.rb, line 29
def self.obfuscate_value(value, allowlist = ALLOWLIST)
  if value.is_a?(Hash)
    obfuscate_statement(value, allowlist)
  elsif value.is_a?(Array)
    value.map { |v| obfuscate_value(v, allowlist) }
  else
    QUESTION_MARK
  end
end