class Airbrake::FaradaySender
Attributes
faraday_middleware[RW]
Public Class Methods
new(configuration)
click to toggle source
# File lib/airbrake/faraday_sender.rb, line 14 def initialize(configuration) @configuration = configuration end
Public Instance Methods
send_to_airbrake(data)
click to toggle source
Override the send to airbrake method
# File lib/airbrake/faraday_sender.rb, line 19 def send_to_airbrake(data) log :debug, "Sending request to #{url.to_s}:\n#{data}" response = begin log :info, "Starting post::: #{url.path}" connection.post(url.path, data) do |req| req.headers = Airbrake::HEADERS end rescue Faraday::Error::ClientError => e log :error, "Error contacting Airbrake server: #{e.message}" return end log :info, "Success: #{response.class}", response if response.respond_to?(:body) error_id = response.body.match(%r{<error-id[^>]*>(.*?)</error-id>}) error_id[1] if error_id end end
Private Instance Methods
connection()
click to toggle source
Define the farday connection
# File lib/airbrake/faraday_sender.rb, line 43 def connection ssl = {} if secure ssl[:use_ssl] = true ssl[:ca_file] = OpenSSL::X509::DEFAULT_CERT_FILE if File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE) ssl[:verify_mode] = OpenSSL::SSL::VERIFY_PEER else ssl[:use_ssl] = false end Faraday.new("#{url.scheme}://#{url.host}", { :ssl => ssl, :request => {:open_timeout => http_open_timeout, :timeout => http_read_timeout} }) do |builder| builder.response :raise_error if self.class.faraday_middleware self.class.faraday_middleware.call(builder) else builder.adapter Faraday.default_adapter end end end
log(level, message, response = nil)
click to toggle source
# File lib/airbrake/faraday_sender.rb, line 71 def log(level, message, response = nil) logger.send level, LOG_PREFIX + message if logger Airbrake.report_environment_info Airbrake.report_response_body(response.body) if response && response.respond_to?(:body) end
logger()
click to toggle source
# File lib/airbrake/faraday_sender.rb, line 77 def logger Airbrake.logger end
url()
click to toggle source
# File lib/airbrake/faraday_sender.rb, line 67 def url URI.parse("#{protocol}://#{host}:#{port}").merge(Airbrake::Sender::NOTICES_URI) end