lib/elastic_apm/spies/faraday.rb in elastic-apm-2.6.1 vs lib/elastic_apm/spies/faraday.rb in elastic-apm-2.7.0

- old
+ new

@@ -3,10 +3,18 @@ module ElasticAPM # @api private module Spies # @api private class FaradaySpy + def self.without_net_http + return yield unless defined?(NetHTTPSpy) + + ElasticAPM::Spies::NetHTTPSpy.disable_in do + yield + end + end + # rubocop:disable Metrics/MethodLength, Metrics/AbcSize # rubocop:disable Metrics/BlockLength, Metrics/PerceivedComplexity # rubocop:disable Metrics/CyclomaticComplexity def install ::Faraday::Connection.class_eval do @@ -30,10 +38,10 @@ name = "#{method.upcase} #{host}" type = "ext.faraday.#{method}" ElasticAPM.with_span name, type do |span| - ElasticAPM::Spies::NetHTTPSpy.disable_in do + ElasticAPM::Spies::FaradaySpy.without_net_http do trace_context = span&.trace_context || transaction.trace_context run_request_without_apm(method, url, body, headers) do |req| req['Elastic-Apm-Traceparent'] = trace_context.to_header