class ScoutApm::Instruments::Memcached

Attributes

context[R]

Public Class Methods

new(context) click to toggle source
# File lib/scout_apm/instruments/memcached.rb, line 6
def initialize(context)
  @context = context
  @installed = false
end

Public Instance Methods

install() click to toggle source
# File lib/scout_apm/instruments/memcached.rb, line 19
def install
  if defined?(::Dalli) && defined?(::Dalli::Client)
    @installed = true

    logger.info "Instrumenting Memcached"

    ::Dalli::Client.class_eval do
      include ScoutApm::Tracer

      def perform_with_scout_instruments(*args, &block)
        command = args.first rescue "Unknown"

        self.class.instrument("Memcached", command) do
          perform_without_scout_instruments(*args, &block)
        end
      end

      alias_method :perform_without_scout_instruments, :perform
      alias_method :perform, :perform_with_scout_instruments
    end
  end
end
installed?() click to toggle source
# File lib/scout_apm/instruments/memcached.rb, line 15
def installed?
  @installed
end
logger() click to toggle source
# File lib/scout_apm/instruments/memcached.rb, line 11
def logger
  context.logger
end
perform_with_scout_instruments(*args, &block) click to toggle source
# File lib/scout_apm/instruments/memcached.rb, line 28
def perform_with_scout_instruments(*args, &block)
  command = args.first rescue "Unknown"

  self.class.instrument("Memcached", command) do
    perform_without_scout_instruments(*args, &block)
  end
end