Module: Datadog::Tracing::Contrib::ActionView::Patcher

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

Overview

Patcher enables patching of ActionView module.

Class Method Summary collapse

Methods included from Patcher

included

Class Method Details

.patchObject



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

def patch
  patch_renderer
end

.patch_rendererObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/datadog/tracing/contrib/action_view/patcher.rb', line 27

def patch_renderer
  if target_version >= Gem::Version.new('4.0.0')
    Events.subscribe!
  elsif defined?(::ActionView::TemplateRenderer) && defined?(::ActionView::PartialRenderer)
    # Rails < 4.0 compatibility:
    #  Rendering events are not nested in this version, creating
    #  render_partial spans outside of the parent render_template span.
    #  We fall back to manual patching instead.
    ::ActionView::TemplateRenderer.prepend(Instrumentation::TemplateRenderer::RailsLessThan4)
    ::ActionView::PartialRenderer.prepend(Instrumentation::PartialRenderer::RailsLessThan4)
  else
    Datadog.logger.debug('Expected Template/Partial classes not found; template rendering disabled')
  end
end

.target_versionObject



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

def target_version
  Integration.version
end