Module: Datadog::Contrib::Dalli::Patcher

Includes:
Patcher
Defined in:
lib/ddtrace/contrib/dalli/patcher.rb

Overview

Patcher enables patching of ‘dalli’ module.

Defined Under Namespace

Classes: DeprecatedPin

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.add_pin!Object

DEPRECATED: Only kept for users still using ‘Dalli.datadog_pin` to configure.

Replaced by configuration API, i.e. `c.use :dalli`.


32
33
34
35
36
37
38
39
40
# File 'lib/ddtrace/contrib/dalli/patcher.rb', line 32

def add_pin!
  DeprecatedPin
    .new(
      get_option(:service_name),
      app: Ext::APP,
      app_type: Datadog::Ext::AppTypes::CACHE,
      tracer: get_option(:tracer)
    ).onto(::Dalli)
end

.get_option(option) ⇒ Object



42
43
44
# File 'lib/ddtrace/contrib/dalli/patcher.rb', line 42

def get_option(option)
  Datadog.configuration[:dalli].get_option(option)
end

.patchObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/ddtrace/contrib/dalli/patcher.rb', line 19

def patch
  do_once(:dalli) do
    begin
      add_pin!
      ::Dalli::Server.send(:include, Instrumentation)
    rescue StandardError => e
      Datadog::Tracer.log.error("Unable to apply Dalli integration: #{e}")
    end
  end
end

.patched?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/ddtrace/contrib/dalli/patcher.rb', line 15

def patched?
  done?(:dalli)
end