Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrafanie/e9e279320ed5a68142c510168e851eec to your computer and use it in GitHub Desktop.
Save jrafanie/e9e279320ed5a68142c510168e851eec to your computer and use it in GitHub Desktop.
Debug faraday requests in ManageIQ
# put me in config/initializers
# restart your appliances and it should now log all the net/http interactions
# ***** WARNING *****
# do not run in production, set_debug_output has this warning in ruby docs:
# WARNING This method opens a serious security hole. Never use this method in production code.
require 'manageiq-api-client'
require 'faraday'
require 'faraday/adapter/net_http'
module FaradayDebug
def net_http_connection(env)
super.tap do |http|
http.set_debug_output($log)
$log.info("XXX #{Process.pid} faraday debug: #{http.read_timeout}")
$log.info("XXX #{Process.pid} faraday debug: #{http.open_timeout}")
http.read_timeout = 300
http.open_timeout = 300
$log.info("XXX #{Process.pid} faraday debug: #{http.read_timeout}")
$log.info("XXX #{Process.pid} faraday debug: #{http.open_timeout}")
end
end
end
Faraday::Adapter::NetHttp.prepend(FaradayDebug)
# you can run an individual request with plain ruby by setting the requested url and user/password
#
# ***** WARNING *****
# do not run in production, set_debug_output has this warning in ruby docs:
# WARNING This method opens a serious security hole. Never use this method in production code.
require 'manageiq-api-client'
require 'faraday'
require 'faraday/adapter/net_http'
module FaradayDebug
def net_http_connection(env)
super.tap do |http|
http.set_debug_output($stderr)
$stderr.puts http.read_timeout
$stderr.puts http.open_timeout
http.read_timeout = 300
http.open_timeout = 300
$stderr.puts http.read_timeout
$stderr.puts http.open_timeout
end
end
end
Faraday::Adapter::NetHttp.prepend(FaradayDebug)
ManageIQ::API::Client.new(:url => 'http://localhost:3000', :user => 'XXX', :password => 'XXX'); nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment