module Labkit::Tracing::Rails::ActionView

Constants

ActionViewSubscriber
COMPONENT_TAG

Public Class Methods

template_identifier(payload) click to toggle source

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.

# 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