Module: Datadog::Tracing::Contrib::ActiveJob::Patcher

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

Overview

Patcher enables patching of 'active_job' module.

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.inject_data_streamsObject



39
40
41
42
43
44
45
46
47
# File 'lib/datadog/tracing/contrib/active_job/patcher.rb', line 39

def inject_data_streams
  # ActiveJob 4.2 deserializes jobs through a class method rather than the
  # instance method, so the DSM pathway can only be propagated on 5.0+.
  return if ::ActiveJob.gem_version < Gem::Version.new("5.0.0")

  ::ActiveSupport.on_load(:active_job) do
    prepend DataStreams
  end
end

.inject_log_correlationObject



29
30
31
32
33
34
35
36
37
# File 'lib/datadog/tracing/contrib/active_job/patcher.rb', line 29

def inject_log_correlation
  ::ActiveSupport.on_load(:active_job) do
    if ::ActiveJob.gem_version < Gem::Version.new("6.0.0")
      include LogInjection::AroundPerformPatch
    else
      include LogInjection::PerformNowPatch
    end
  end
end

.patchObject



23
24
25
26
27
# File 'lib/datadog/tracing/contrib/active_job/patcher.rb', line 23

def patch
  Events.subscribe!
  inject_log_correlation
  inject_data_streams
end

.target_versionObject



19
20
21
# File 'lib/datadog/tracing/contrib/active_job/patcher.rb', line 19

def target_version
  Integration.version
end