Sha256: 2f748c523413be208f058801142b4ac81e32bd5cd3d437ab58e9ba6ed9df76ae

Contents?: true

Size: 986 Bytes

Versions: 6

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: 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

6 entries across 6 versions & 1 rubygems

Version Path
datadog-2.3.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
datadog-2.2.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
datadog-2.1.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
datadog-2.0.0 lib/datadog/tracing/contrib/httpclient/patcher.rb
datadog-2.0.0.beta2 lib/datadog/tracing/contrib/httpclient/patcher.rb
datadog-2.0.0.beta1 lib/datadog/tracing/contrib/httpclient/patcher.rb