Sha256: fe0e3fa03fe5e98633abdc58f43d0e6b7d010e4f5da4522792be8f6d48fceca7

Contents?: true

Size: 1.21 KB

Versions: 33

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

require 'one_apm/agent/datastore/mongo/obfuscator'

module OneApm
  module Agent
    module Datastore
      module Mongo
        module StatementFormatter

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

          OBFUSCATE_KEYS = [
            :selector
          ]

          def self.format(statement, operation)
            return nil unless OneApm::Manager.config[:'mongo.capture_queries']

            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

          def self.obfuscate(statement)
            statement = Obfuscator.obfuscate_statement(statement) if OneApm::Manager.config[:'mongo.obfuscate_queries']
            statement
          end
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
oneapm_rpm-1.3.6 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.6.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.5 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.5.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.4 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.4.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.3 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.3.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.2 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.2.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.1.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.0 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.3.0.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.2.9 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.2.9.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.2.8 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.2.8.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.2.7 lib/one_apm/agent/datastore/mongo/statement_formatter.rb
oneapm_rpm-1.2.7.rc1 lib/one_apm/agent/datastore/mongo/statement_formatter.rb