Module: Datadog::Tracing::Contrib::ActionView::Instrumentation::PartialRenderer

Included in:
RailsLessThan4
Defined in:
lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb

Overview

Legacy instrumentation for partial rendering for Rails < 4

Defined Under Namespace

Modules: RailsLessThan4

Instance Method Summary collapse

Instance Method Details

#datadog_render_partial(template) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb', line 36

def datadog_render_partial(template)
  template_name = Utils.normalize_template_name(template.try('identifier'))

  if template_name
    active_datadog_span.resource = template_name
    active_datadog_span.set_tag(
      Ext::TAG_TEMPLATE_NAME,
      template_name
    )

    # Measure service stats
    Contrib::Analytics.set_measured(active_datadog_span)
  end
end

#render(*args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb', line 11

def render(*args, &block)
  Tracing.trace(
    Ext::SPAN_RENDER_PARTIAL,
    span_type: Tracing::Metadata::Ext::HTTP::TYPE_TEMPLATE
  ) do |span|
    span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
    span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_RENDER_PARTIAL)

    with_datadog_span(span) { super(*args) }
  end
end

#render_partial(*args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/datadog/tracing/contrib/action_view/instrumentation/partial_renderer.rb', line 23

def render_partial(*args)
  begin
    template = datadog_template(*args)

    datadog_render_partial(template)
  rescue StandardError => e
    Datadog.logger.debug(e.message)
  end

  # execute the original function anyway
  super(*args)
end