Sha256: 3cf6ab6b665cb402f7fe9fc44d9369ba13b1cbff6ccdc17e2cff25b633897368

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 Bytes

Contents

# typed: true
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.include(Instrumentation)
            rescue StandardError => e
              Datadog.logger.error("Unable to apply httpclient integration: #{e}")
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-0.54.2 lib/ddtrace/contrib/httpclient/patcher.rb
ddtrace-0.54.1 lib/ddtrace/contrib/httpclient/patcher.rb
ddtrace-0.54.0 lib/ddtrace/contrib/httpclient/patcher.rb
ddtrace-0.53.0 lib/ddtrace/contrib/httpclient/patcher.rb
ddtrace-0.52.0 lib/ddtrace/contrib/httpclient/patcher.rb