Sha256: df087f32c552c54d112c3d743c3da568b73f34ccd5a06e7eb13ed1d8460b9639

Contents?: true

Size: 940 Bytes

Versions: 7

Compression:

Stored size: 940 Bytes

Contents

if defined?(::Moped)
  ProfileIt::Agent.instance.logger.debug "Instrumenting Moped"
  Moped::Node.class_eval do
    include ProfileIt::Tracer
    def process_with_profile_it_instruments(operation, &callback)
      if operation.respond_to?(:collection)
        collection = operation.collection
        self.class.instrument("MongoDB/Process/#{collection}/#{operation.class.to_s.split('::').last}", :desc => profile_it_sanitize_log(operation.log_inspect)) do
          process_without_profile_it_instruments(operation, &callback)
        end
      end
    end
    alias_method :process_without_profile_it_instruments, :process
    alias_method :process, :process_with_profile_it_instruments
    
    # replaces values w/ ?
    def profile_it_sanitize_log(log)
      return nil if log.length > 1000 # safeguard - don't sanitize large SQL statements
      log.gsub(/(=>")((?:[^"]|"")*)"/) do 
        $1 + '?' + '"'
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
profile_it-0.2.9 lib/profile_it/instruments/moped_instruments.rb
profile_it-0.2.8.1 lib/profile_it/instruments/moped_instruments.rb
profile_it-0.2.8 lib/profile_it/instruments/moped_instruments.rb
profile_it-0.2.7 lib/profile_it/instruments/moped_instruments.rb
profile_it-0.2.6 lib/profile_it/instruments/moped_instruments.rb
profile_it-0.2.5 lib/profile_it/instruments/moped_instruments.rb
profile_it-0.2.4 lib/profile_it/instruments/moped_instruments.rb