Sha256: e52d50e8e01f7f3589844bfcd261859537aaf71b7903097a585741d648c054cd

Contents?: true

Size: 871 Bytes

Versions: 3

Compression:

Stored size: 871 Bytes

Contents

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

module Datadog
  module Contrib
    # Datadog Httprb integration.
    module Httprb
      # Patcher enables patching of 'httprb' 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
              ::HTTP::Client.include(Instrumentation)
            rescue StandardError => e
              Datadog::Logger.error("Unable to apply httprb integration: #{e}")
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ddtrace-0.51.1 lib/ddtrace/contrib/httprb/patcher.rb
ddtrace-0.51.0 lib/ddtrace/contrib/httprb/patcher.rb
ddtrace-0.50.0 lib/ddtrace/contrib/httprb/patcher.rb