Method: LightStep::Transport::HTTPJSON::Failbot#report

Defined in:
lib/hubstep/failbot.rb

#report(report) ⇒ Object

There’s no way to call through to the normal implementation while getting access to the request/response objects, so we just copy all the code here.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/hubstep/failbot.rb', line 17

def report(report) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  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

  ::Failbot.push(request_body: req.body)

  res = https.request(req)

  puts res.to_s, res.body if @verbose >= 3

  track_error(res)

  nil
ensure
  ::Failbot.report!($ERROR_INFO, app: "lightstep") if $ERROR_INFO
  ::Failbot.pop
end