Class: RSolr::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/patches/db/rsolr.rb

Instance Method Summary collapse

Instance Method Details

#execute_with_profiling(client, request_context) ⇒ Object Also known as: execute



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/patches/db/rsolr.rb', line 5

def execute_with_profiling(client, request_context)
  return execute_without_profiling(client, request_context) unless SqlPatches.should_measure?

  start        = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  result       = execute_without_profiling(client, request_context)
  elapsed_time = SqlPatches.elapsed_time(start)

  data = "#{request_context[:method].upcase} #{request_context[:uri]}".dup
  if (request_context[:method] == :post) && request_context[:data]
    if request_context[:headers].include?("Content-Type") && (request_context[:headers]["Content-Type"] == "text/xml")
      # it's xml, unescaping isn't needed
      data << "\n#{request_context[:data]}"
    else
      data << "\n#{Rack::Utils.unescape(request_context[:data])}"
    end
  end
  ::Rack::MiniProfiler.record_sql(data, elapsed_time)

  result
end