Skip to content

Instrumentation

Mislav Marohnić edited this page Jan 24, 2012 · 1 revision

Instrumenting requests with Active Support

FaradayMiddleware::Instrumentation uses Active Support to instrument requests. It records information about each request and time spent performing it.

conn.use :instrumentation

The default key under which all requests are instrumented is "request.faraday". You can subscribe to these events and log them accordingly:

ActiveSupport::Notifications.subscribe('request.faraday') do |name, start_time, end_time, _, env|
  url = env[:url]
  http_method = env[:method].to_s.upcase
  duration = end_time - start_time
  $stderr.puts '[%s] %s %s (%.3f s)' % [url.host, http_method, url.request_uri, duration]
end

(Please note: This wiki has been closed, and turned into in-repo Markdown documents. You can find them in the repository's docs/ directory. This wiki does not take new edits.)

Clone this wiki locally