Module: LightStep::Transport::HTTPJSON::Failbot
- Included in:
- LightStep::Transport::HTTPJSON
- Defined in:
- lib/hubstep/failbot.rb
Overview
This reimplementation of LightStep::Transport::HTTPJSON#report reports network errors and other exceptions to Failbot.
Defined Under Namespace
Classes: HTTPError
Instance Method Summary collapse
-
#report(report) ⇒ Object
There’s no way to call through to the normal implementation while getting access to the response object, so we just copy all the code here.
- #track_error(res) ⇒ Object
Instance Method Details
#report(report) ⇒ Object
There’s no way to call through to the normal implementation while getting access to the response object, so we just copy all the code here.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hubstep/failbot.rb', line 16 def report(report) # rubocop:disable Metrics/AbcSize p report if @verbose >= 3 https = Net::HTTP.new(@host, @port) https.use_ssl = @encryption == ENCRYPTION_TLS req = Net::HTTP::Post.new("/api/v0/reports") req["LightStep-Access-Token"] = @access_token req["Content-Type"] = "application/json" req["Connection"] = "keep-alive" req.body = report.to_json res = https.request(req) puts res.to_s, res.body if @verbose >= 3 track_error(res) nil ensure ::Failbot.report!($ERROR_INFO) if $ERROR_INFO end |
#track_error(res) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/hubstep/failbot.rb', line 37 def track_error(res) return unless res.is_a?(Net::HTTPClientError) || res.is_a?(Net::HTTPServerError) exception = HTTPError.new("#{res.code} #{res.}") exception.set_backtrace(caller) ::Failbot.report!(exception, response_body: res.body, response_uri: res.uri) end |