Method: Datadog::Tracing::Contrib::MongoDB.query_builder

Defined in:
lib/datadog/tracing/contrib/mongodb/parsers.rb

.query_builder(command_name, database_name, command) ⇒ Object

returns a formatted and normalized query



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/datadog/tracing/contrib/mongodb/parsers.rb', line 21

def query_builder(command_name, database_name, command)
  # always exclude the command name
  options = Contrib::Utils::Quantization::Hash.merge_options(quantization_options, exclude: [command_name.to_s])

  # quantized statements keys are strings to avoid leaking Symbols in older Rubies
  # as Symbols are not GC'ed in Rubies prior to 2.2
  base_info = Contrib::Utils::Quantization::Hash.format(
    {
      'operation' => command_name,
      'database' => database_name,
      'collection' => command.values.first
    },
    options
  )

  base_info.merge(Contrib::Utils::Quantization::Hash.format(command, options))
end