No commit activity in last 3 years
No release in over 3 years
Includes the request time in a Faraday response
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.5
~> 5.11.3
~> 1.1.0
>= 0

Runtime

>= 0.9.0
 Project Readme

Faraday::Request::Timer

A gem for timing Faraday requests. Faraday has an instrumentation middleware, but it uses ActiveSupport::Notifications.

ActiveSupport::Notifications.subscribe("request.faraday") do |name, starts, ends, _, env|
  url      = env[:url]
  duration = ends - starts

  puts "The request to #{url} took #{duration} seconds."
end

That's great if you want to log request times out-of-band, but not so useful if you need to do something specific with that time in-band, right after the request was made. For that you need Faraday::Request::Timer.

Installation

Add this line to your application's Gemfile:

gem 'faraday-request-timer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install faraday-request-timer

Usage

connection = Faraday::Connection.new do |builder|
  builder.request :timer
  builder.adapter Faraday.default_adapter
end

response = connection.get("https://canaryup.com")
response.env[:duration]
# => 0.130454

Contributing

  1. Fork it ( http://github.com/canaryup/faraday-request-timer/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request