Module: NewRelic::Agent::Instrumentation::ViewComponent
- Included in:
- ViewComponent::Prepend
- Defined in:
- lib/new_relic/agent/instrumentation/view_component/instrumentation.rb
Defined Under Namespace
Constant Summary collapse
Instance Method Summary collapse
- #metric_name(identifier, component) ⇒ Object
- #metric_path(identifier) ⇒ Object
- #render_in_with_tracing(*args) ⇒ Object
Instance Method Details
#metric_name(identifier, component) ⇒ Object
25 26 27 |
# File 'lib/new_relic/agent/instrumentation/view_component/instrumentation.rb', line 25 def metric_name(identifier, component) "View/#{metric_path(identifier)}/#{component}" end |
#metric_path(identifier) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/new_relic/agent/instrumentation/view_component/instrumentation.rb', line 29 def metric_path(identifier) return 'component' unless identifier if (parts = identifier.split('/')).size > 1 parts[-2..-1].join('/') # Get filepath by assuming the Rails' structure: app/components/home/example_component.rb else NewRelic::Agent::UNKNOWN_METRIC end end |
#render_in_with_tracing(*args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/new_relic/agent/instrumentation/view_component/instrumentation.rb', line 9 def render_in_with_tracing(*args) NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME) begin segment = NewRelic::Agent::Tracer.start_segment( name: metric_name(self.class.identifier, self.class.name) ) yield rescue => e NewRelic::Agent.notice_error(e) raise ensure segment&.finish end end |