module NewRelic::Agent::Instrumentation::ViewComponent
Constants
- INSTRUMENTATION_NAME
Public Instance Methods
metric_name()
click to toggle source
# File lib/new_relic/agent/instrumentation/view_component/instrumentation.rb, line 23 def metric_name "View/#{metric_path(self.class.source_location)}/#{self.class.name}" rescue => e NewRelic::Agent.logger.error('Error identifying View Component metric name', e) 'View/component' end
metric_path(identifier)
click to toggle source
# File lib/new_relic/agent/instrumentation/view_component/instrumentation.rb, line 31 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) { || ... }
click to toggle source
# 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) yield rescue => e NewRelic::Agent.notice_error(e) raise ensure segment&.finish end end