Sha256: 923972dce72cd1e9fd231c87c874d0d74fe39d78869064e0b2f64be0b9b8d26f

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 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.send(: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.49.0 lib/ddtrace/contrib/httprb/patcher.rb
ddtrace-0.48.0 lib/ddtrace/contrib/httprb/patcher.rb
ddtrace-0.47.0 lib/ddtrace/contrib/httprb/patcher.rb