Module: BrainzLab::Instrumentation::NetHttp::Patch
- Defined in:
- lib/brainzlab/instrumentation/net_http.rb
Instance Method Summary collapse
Instance Method Details
#inject_trace_context(req) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/brainzlab/instrumentation/net_http.rb', line 47 def inject_trace_context(req) return unless BrainzLab.configuration.pulse_enabled # Build headers hash and inject trace context headers = {} BrainzLab::Pulse.inject(headers, format: :all) # Apply headers to request headers.each do |key, value| req[key] = value end rescue StandardError => e BrainzLab.debug_log("Failed to inject trace context: #{e.}") end |
#request(req, body = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/brainzlab/instrumentation/net_http.rb', line 27 def request(req, body = nil, &) return super unless should_track? # Inject distributed tracing context into outgoing request headers inject_trace_context(req) url = build_url(req) method = req.method started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) begin response = super track_request(method, url, response.code.to_i, started_at) response rescue StandardError => e track_request(method, url, nil, started_at, e.class.name) raise end end |