module Datadog::Contrib::ActionView::Patcher
Patcher
enables patching of ActionView
module.
Public Instance Methods
patch()
click to toggle source
# File lib/ddtrace/contrib/action_view/patcher.rb, line 22 def patch patch_renderer end
patch_renderer()
click to toggle source
# File lib/ddtrace/contrib/action_view/patcher.rb, line 26 def patch_renderer if target_version >= Gem::Version.new('4.0.0') Events.subscribe! elsif defined?(::ActionView::TemplateRenderer) && defined?(::ActionView::PartialRenderer) # Rails < 4 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.send(:prepend, Instrumentation::TemplateRenderer::RailsLessThan4) ::ActionView::PartialRenderer.send(:prepend, Instrumentation::PartialRenderer::RailsLessThan4) elsif defined?(::ActionView::Rendering) && defined?(::ActionView::Partials::PartialRenderer) # NOTE: Rails < 3.1 compatibility: different classes are used ::ActionView::Rendering.send(:prepend, Instrumentation::TemplateRenderer::Rails30) ::ActionView::Partials::PartialRenderer.send(:prepend, Instrumentation::PartialRenderer::RailsLessThan4) else Datadog.logger.debug('Expected Template/Partial classes not found; template rendering disabled') end end
target_version()
click to toggle source
# File lib/ddtrace/contrib/action_view/patcher.rb, line 18 def target_version Integration.version end