Class: HubStep::Transport::HTTPJSON
- Inherits:
-
LightStep::Transport::HTTPJSON
- Object
- LightStep::Transport::HTTPJSON
- HubStep::Transport::HTTPJSON
- Defined in:
- lib/hubstep/transport/http_json.rb
Overview
HTTPJSON is a transport that sends reports via HTTP in JSON format. It is thread-safe, however it is not fork-safe. When forking, all items in the queue will be copied and sent in duplicate.
When forking, you should first ‘disable` the tracer, then `enable` it from within the fork (and in the parent post-fork). See `examples/fork_children/main.rb` for an example.
Instance Method Summary collapse
-
#report(report) ⇒ Object
Queue a report for sending.
Methods included from LightStep::Transport::HTTPJSON::Failbot
Instance Method Details
#report(report) ⇒ Object
Queue a report for sending
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hubstep/transport/http_json.rb', line 26 def report(report) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength p report if @verbose >= 3 HubStep.instrumenter.instrument('lightstep.transport.report', {}) do |payload| 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) payload[:request_body] = req.body puts res.to_s, res.body if @verbose >= 3 payload[:response] = res end nil rescue => e HubStep.instrumenter.instrument('lightstep.transport.error', error: e) end |