Module: Txray::Runtime::NetHttpGuard

Defined in:
lib/txray/runtime.rb

Instance Method Summary collapse

Instance Method Details

#request(req, body = nil) ⇒ Object



210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/txray/runtime.rb', line 210

def request(req, body = nil, &)
  return super unless Txray::Runtime.transaction_open?

  started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  begin
    super
  ensure
    elapsed = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - started) * 1000).round(1)
    Txray::Runtime.violation("http-in-transaction", "#{req.method} #{address}#{req.path} inside an open " \
                                                    "transaction", duration_ms: elapsed)
  end
end