Sha256: 702bdb9aab7d48af14eb26beefcb8b07dc56afce70edec08884a7a6332b95e56

Contents?: true

Size: 970 Bytes

Versions: 12

Compression:

Stored size: 970 Bytes

Contents

# typed: true

require_relative '../../../core/utils/only_once'
require_relative 'instrumentation'
require_relative '../patcher'

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

          PATCH_ONLY_ONCE = Core::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
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.8.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.7.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.6.1 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.6.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.5.2 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.5.1 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.5.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.4.2 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.4.1 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.4.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
ddtrace-1.3.0 lib/datadog/tracing/contrib/httpclient/patcher.rb