Module: Datadog::Contrib::ActiveSupport::Cache::Patcher

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

Overview

Patcher enables patching of ‘active_support’ module.

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.cache_store_class(meth) ⇒ Object



31
32
33
# File 'lib/ddtrace/contrib/active_support/cache/patcher.rb', line 31

def cache_store_class(meth)
  ::ActiveSupport::Cache::Store
end

.patchObject



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

def patch
  do_once(:cache) do
    begin
      patch_cache_store_read
      patch_cache_store_fetch
      patch_cache_store_write
      patch_cache_store_delete
    rescue StandardError => e
      Datadog::Tracer.log.error("Unable to apply Active Support cache integration: #{e}")
    end
  end
end

.patch_cache_store_deleteObject



53
54
55
56
57
# File 'lib/ddtrace/contrib/active_support/cache/patcher.rb', line 53

def patch_cache_store_delete
  do_once(:patch_cache_store_delete) do
    cache_store_class(:delete).send(:prepend, Cache::Instrumentation::Delete)
  end
end

.patch_cache_store_fetchObject



41
42
43
44
45
# File 'lib/ddtrace/contrib/active_support/cache/patcher.rb', line 41

def patch_cache_store_fetch
  do_once(:patch_cache_store_fetch) do
    cache_store_class(:fetch).send(:prepend, Cache::Instrumentation::Fetch)
  end
end

.patch_cache_store_readObject



35
36
37
38
39
# File 'lib/ddtrace/contrib/active_support/cache/patcher.rb', line 35

def patch_cache_store_read
  do_once(:patch_cache_store_read) do
    cache_store_class(:read).send(:prepend, Cache::Instrumentation::Read)
  end
end

.patch_cache_store_writeObject



47
48
49
50
51
# File 'lib/ddtrace/contrib/active_support/cache/patcher.rb', line 47

def patch_cache_store_write
  do_once(:patch_cache_store_write) do
    cache_store_class(:write).send(:prepend, Cache::Instrumentation::Write)
  end
end

.patched?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ddtrace/contrib/active_support/cache/patcher.rb', line 14

def patched?
  done?(:cache)
end