Module: Labkit::Tracing::Rails::ActionView

Defined in:
lib/labkit/tracing/rails/action_view.rb,
lib/labkit/tracing/rails/action_view/subscriber.rb,
lib/labkit/tracing/rails/action_view/render_partial_instrumenter.rb,
lib/labkit/tracing/rails/action_view/render_template_instrumenter.rb,
lib/labkit/tracing/rails/action_view/render_collection_instrumenter.rb

Defined Under Namespace

Classes: RenderCollectionInstrumenter, RenderPartialInstrumenter, RenderTemplateInstrumenter, Subscriber

Constant Summary collapse

COMPONENT_TAG =
"ActionView"

Class Method Summary collapse

Class Method Details

.template_identifier(payload) ⇒ Object

Returns identifier relative to Rails.root. Rails supports different template types and returns corresponding identifiers:

  • Text template: the identifier is “text template”

  • Html template: the identifier is “html template”

  • Inline template: the identifier is “inline template”

  • Raw template: the identifier is the file path of the template

Therefore, the amount of returned identifiers is static.



20
21
22
23
24
25
26
# File 'lib/labkit/tracing/rails/action_view.rb', line 20

def self.template_identifier(payload)
  return if !defined?(::Rails.root) || payload[:identifier].nil?

  # Rails.root returns a Pathname object, whose `to_s` methods returns an absolute path without ending "/"
  # Source: https://github.com/rails/rails/blob/v6.0.3.1/railties/lib/rails.rb#L64
  payload[:identifier].sub("#{::Rails.root}/", "")
end