Sha256: 69be336bc0e8167894aab0be702239ec9af161b19334ce54e5da46bd7363ec62

Contents?: true

Size: 1.24 KB

Versions: 27

Compression:

Stored size: 1.24 KB

Contents

module Datadog
  module Contrib
    module Dalli
      COMPATIBLE_WITH = Gem::Version.new('2.0.0')
      NAME = 'memcached.command'.freeze
      CMD_TAG = 'memcached.command'.freeze

      # Responsible for hooking the instrumentation into `dalli`
      module Patcher
        include Base
        register_as :dalli, auto_patch: true
        option :service_name, default: 'memcached'

        @patched = false

        class << self
          def patch
            return @patched if patched? || !compatible?

            require 'ddtrace/ext/app_types'
            require_relative 'instrumentation'

            add_pin!
            Instrumentation.patch!

            @patched = true
          rescue => e
            Tracer.log.error("Unable to apply Dalli integration: #{e}")
            @patched
          end

          def patched?
            @patched
          end

          private

          def compatible?
            return unless defined?(::Dalli::VERSION)

            Gem::Version.new(::Dalli::VERSION) > COMPATIBLE_WITH
          end

          def add_pin!
            Pin
              .new(get_option(:service_name), app: 'dalli', app_type: Ext::AppTypes::CACHE)
              .onto(::Dalli)
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
ddtrace-0.16.1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.15.0.internaltracinfeature1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.16.0 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.2.disableprotocolversion4 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.15.0 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.2.withoutpriorityparsing1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.2 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.15.0.beta1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.0 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.0.rc1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.13.2 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.0.beta2 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.14.0.beta1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.13.1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.13.0 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.12.1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.13.0.beta1 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.12.0 lib/ddtrace/contrib/dalli/patcher.rb
ddtrace-0.12.0.rc1 lib/ddtrace/contrib/dalli/patcher.rb