class Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter

def self.apply_strategy(strategy, val)

Applies strategy on hash values based on keys
def self.apply_strategy(strategy, val)
  case strategy
  when :allow      then val
  when :deny       then "?"
  when :deny_array then "[?]"
  when :sanitize_document
    Appsignal::Utils::QueryParamsSanitizer.sanitize(val, true, :mongodb)
  when :sanitize_bulk
    if val.length > 1
      [
        format(:bulk, val.first),
        "[...]"
      ]
    else
      val.map { |v| format(:bulk, v) }
    end
  else "?"
  end
end

def self.format(strategy, command)

Format command based on given strategy
def self.format(strategy, command)
  # Stop processing if command is not a hash
  return {} unless command.is_a?(Hash)
  # Get the strategy and stop if it's not present
  strategies = ALLOWED[strategy.to_s]
  return {} unless strategies
  {}.tap do |hsh|
    command.each do |key, val|
      hsh[key] = apply_strategy(strategies[key], val)
    end
  end
end