Sha256: 2382679017d75e5a01f191b47d8de513b31abd7aa57560826ae16084bc1b70a1

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

# typed: false

require 'datadog/tracing'
require 'datadog/tracing/metadata/ext'
require 'datadog/tracing/contrib/analytics'
require 'datadog/tracing/contrib/action_view/ext'
require 'datadog/tracing/contrib/action_view/event'

module Datadog
  module Tracing
    module Contrib
      module ActionView
        module Events
          # Defines instrumentation for render_template.action_view event
          module RenderTemplate
            include ActionView::Event

            EVENT_NAME = 'render_template.action_view'.freeze

            module_function

            def event_name
              self::EVENT_NAME
            end

            def span_name
              Ext::SPAN_RENDER_TEMPLATE
            end

            def process(span, _event, _id, payload)
              span.service = configuration[:service_name] if configuration[:service_name]
              span.span_type = Tracing::Metadata::Ext::HTTP::TYPE_TEMPLATE

              span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)
              span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_RENDER_TEMPLATE)

              if (template_name = Utils.normalize_template_name(payload[:identifier]))
                span.resource = template_name
                span.set_tag(Ext::TAG_TEMPLATE_NAME, template_name)
              end

              layout = payload[:layout]
              span.set_tag(Ext::TAG_LAYOUT, layout) if layout

              # Measure service stats
              Contrib::Analytics.set_measured(span)

              record_exception(span, payload)
            rescue StandardError => e
              Datadog.logger.debug(e.message)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddtrace-1.2.0 lib/datadog/tracing/contrib/action_view/events/render_template.rb
ddtrace-1.1.0 lib/datadog/tracing/contrib/action_view/events/render_template.rb
ddtrace-1.0.0 lib/datadog/tracing/contrib/action_view/events/render_template.rb
ddtrace-1.0.0.beta2 lib/datadog/tracing/contrib/action_view/events/render_template.rb