Module: TingYun::Instrumentation::Support::MongoFormatter

Defined in:
lib/ting_yun/instrumentation/support/mongo_formatter.rb

Constant Summary collapse

PLAINTEXT_KEYS =
[
    :database,
    :collection,
    :operation,
    :fields,
    :skip,
    :limit,
    :order
]
OBFUSCATE_KEYS =
[
    :selector
]

Class Method Summary collapse

Class Method Details

.format(statement, operation) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ting_yun/instrumentation/support/mongo_formatter.rb', line 25

def self.format(statement, operation)

  result = {:operation => operation}

  PLAINTEXT_KEYS.each do |key|
    result[key] = statement[key] if statement.key?(key)
  end

  OBFUSCATE_KEYS.each do |key|
    if statement.key?(key) && statement[key]
      obfuscated = obfuscate(statement[key])
      result[key] = obfuscated if obfuscated
    end
  end
  result
end

.obfuscate(statement) ⇒ Object



42
43
44
45
# File 'lib/ting_yun/instrumentation/support/mongo_formatter.rb', line 42

def self.obfuscate(statement)
  statement = Obfuscator.obfuscate_statement(statement)
  statement
end