Sha256: 830e130a0ff31c8e1147ae046db0ac872b016587929fe245cefe2238d2b3a0ad

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

require 'ddtrace/contrib/patcher'
require 'ddtrace/contrib/httpclient/instrumentation'
require 'ddtrace/utils/only_once'

module Datadog
  module Contrib
    # Datadog Httpclient integration.
    module Httpclient
      # Patcher enables patching of 'httpclient' module.
      module Patcher
        include Contrib::Patcher

        PATCH_ONLY_ONCE = Datadog::Utils::OnlyOnce.new

        module_function

        def patched?
          PATCH_ONLY_ONCE.ran?
        end

        def target_version
          Integration.version
        end

        # patch applies our patch
        def patch
          PATCH_ONLY_ONCE.run do
            begin
              ::HTTPClient.send(:include, Instrumentation)
            rescue StandardError => e
              Datadog::Logger.error("Unable to apply httpclient integration: #{e}")
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddtrace-0.49.0 lib/ddtrace/contrib/httpclient/patcher.rb
ddtrace-0.48.0 lib/ddtrace/contrib/httpclient/patcher.rb
ddtrace-0.47.0 lib/ddtrace/contrib/httpclient/patcher.rb