Module: ViewComponent::Instrumentation
- Defined in:
- lib/view_component/instrumentation.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(mod) ⇒ Object
7 8 9 |
# File 'lib/view_component/instrumentation.rb', line 7 def self.included(mod) mod.prepend(self) unless self <= ViewComponent::Instrumentation end |
Instance Method Details
#around_render ⇒ Object
32 33 34 35 36 |
# File 'lib/view_component/instrumentation.rb', line 32 def around_render result = super @__vc_instrumentation_view_identifier = current_template&.path result end |
#render_in(view_context, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/view_component/instrumentation.rb', line 11 def render_in(view_context, &block) return super if !Rails.application.config.view_component.instrumentation_enabled.present? payload = { name: self.class.name, identifier: self.class.identifier, view_identifier: nil } ActiveSupport::Notifications.instrument( "render.view_component", payload ) do result = super payload[:view_identifier] = @__vc_instrumentation_view_identifier result end ensure @__vc_instrumentation_view_identifier = nil end |