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

Includes:
Patcher
Defined in:
lib/datadog/tracing/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

This method is overwritten by ‘datadog/tracing/contrib/active_support/cache/redis.rb` with more complex behavior.



34
35
36
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 34

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

.patchObject



21
22
23
24
25
26
27
28
29
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 21

def patch
  patch_cache_store_read
  patch_cache_store_read_multi
  patch_cache_store_fetch
  patch_cache_store_fetch_multi
  patch_cache_store_write
  patch_cache_store_write_multi
  patch_cache_store_delete
end

.patch_cache_store_deleteObject



68
69
70
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 68

def patch_cache_store_delete
  cache_store_class(:delete).prepend(Cache::Instrumentation::Delete)
end

.patch_cache_store_fetchObject



46
47
48
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 46

def patch_cache_store_fetch
  cache_store_class(:fetch).prepend(Cache::Instrumentation::Fetch)
end

.patch_cache_store_fetch_multiObject



50
51
52
53
54
55
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 50

def patch_cache_store_fetch_multi
  klass = cache_store_class(:fetch_multi)
  return unless klass.public_method_defined?(:fetch_multi)

  klass.prepend(Cache::Instrumentation::FetchMulti)
end

.patch_cache_store_readObject



38
39
40
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 38

def patch_cache_store_read
  cache_store_class(:read).prepend(Cache::Instrumentation::Read)
end

.patch_cache_store_read_multiObject



42
43
44
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 42

def patch_cache_store_read_multi
  cache_store_class(:read_multi).prepend(Cache::Instrumentation::ReadMulti)
end

.patch_cache_store_writeObject



57
58
59
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 57

def patch_cache_store_write
  cache_store_class(:write).prepend(Cache::Instrumentation::Write)
end

.patch_cache_store_write_multiObject



61
62
63
64
65
66
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 61

def patch_cache_store_write_multi
  klass = cache_store_class(:write_multi)
  return unless klass.public_method_defined?(:write_multi)

  klass.prepend(Cache::Instrumentation::WriteMulti)
end

.target_versionObject



17
18
19
# File 'lib/datadog/tracing/contrib/active_support/cache/patcher.rb', line 17

def target_version
  Integration.version
end