class ElasticAPM::Spies::NetHTTPSpy
def install
def install Net::HTTP.class_eval do alias request_without_apm request def request(req, body = nil, &block) unless (transaction = ElasticAPM.current_transaction) return request_without_apm(req, body, &block) end if ElasticAPM::Spies::NetHTTPSpy.disabled? return request_without_apm(req, body, &block) end host, = req['host'] && req['host'].split(':') method = req.method host ||= address name = "#{method} #{host}" ElasticAPM.with_span( name, TYPE, subtype: SUBTYPE, action: method.to_s ) do |span| trace_context = span&.trace_context || transaction.trace_context req['Elastic-Apm-Traceparent'] = trace_context.to_header request_without_apm(req, body, &block) end end end end