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_patch ⇒ Object

Propagate tracing context in Concurrent::Async



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

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

.patch ⇒ Object



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

def self.patch
  require_relative "future_patch"
  patch_future
  require_relative "promises_future_patch"
  patch_promises_future
  require_relative "async_patch"
  async_patch
end

.patch_future ⇒ Object

Propagate tracing context in Concurrent::Future



35
36
37
# File 'lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb', line 35

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

.patch_promises_future ⇒ Object

Propagate tracing context in Concurrent::Promises::Future



40
41
42
# File 'lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb', line 40

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

.target_version ⇒ Object



13
14
15
# File 'lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb', line 13

def self.target_version
  Integration.version
end