class Fluent::BugsnagOutput
Public Instance Methods
format(tag, time, record)
click to toggle source
# File lib/fluent/plugin/out_bugsnag.rb, line 14 def format(tag, time, record) [tag, time, record].to_msgpack end
write(chunk)
click to toggle source
# File lib/fluent/plugin/out_bugsnag.rb, line 18 def write(chunk) chunk.msgpack_each do |(tag,time,record)| options = record['options'] || {} request(record['url'], record['body'], options) end end
Private Instance Methods
default_headers()
click to toggle source
# File lib/fluent/plugin/out_bugsnag.rb, line 52 def default_headers { "Content-Type" => "application/json", } end
path(uri)
click to toggle source
# File lib/fluent/plugin/out_bugsnag.rb, line 48 def path(uri) uri.path == "" ? "/" : uri.path end
request(url, body, options = {})
click to toggle source
# File lib/fluent/plugin/out_bugsnag.rb, line 27 def request(url, body, options = {}) uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port, @bugsnag_proxy_host, @bugsnag_proxy_port, @bugsnag_proxy_user, @bugsnag_proxy_password) http.read_timeout = @bugsnag_timeout http.open_timeout = @bugsnag_timeout if uri.scheme == "https" http.use_ssl = true # the default in 1.9+, but required for 1.8 # http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.verify_mode = OpenSSL::SSL::VERIFY_NONE end headers = options.key?('headers') ? options['headers'] : {} headers.merge!(default_headers) request = Net::HTTP::Post.new(path(uri), headers) request.body = body http.request(request) end