Module: Datadog::Tracing::Contrib::ConcurrentRuby::Patcher

Includes:
Patcher
Defined in:
lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb

Overview

Patcher enables patching of ‘Future’ and ‘Async’ classes.

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.async_patchObject

Propagate tracing context in Concurrent::Async



29
30
31
32
33
34
# File 'lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb', line 29

def async_patch
  if defined?(::Concurrent::Async)
    # NOTE: AsyncDelegator is a private constant
    ::Concurrent::Async.const_get(:AsyncDelegator).prepend(AsyncPatch)
  end
end

.patchObject



19
20
21
22
23
24
25
26
# File 'lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb', line 19

def patch
  require_relative 'future_patch'
  patch_future
  require_relative 'promises_future_patch'
  patch_promises_future
  require_relative 'async_patch'
  async_patch
end

.patch_futureObject

Propagate tracing context in Concurrent::Future



37
38
39
# File 'lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb', line 37

def patch_future
  ::Concurrent::Future.prepend(FuturePatch) if defined?(::Concurrent::Future)
end

.patch_promises_futureObject

Propagate tracing context in Concurrent::Promises::Future



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

def patch_promises_future
  ::Concurrent::Promises.singleton_class.prepend(PromisesFuturePatch) if defined?(::Concurrent::Promises::Future)
end

.target_versionObject



15
16
17
# File 'lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb', line 15

def target_version
  Integration.version
end