Module: NewRelic::Agent::Instrumentation::Tilt
- Included in:
- Prepend
- Defined in:
- lib/new_relic/agent/instrumentation/tilt/chain.rb,
lib/new_relic/agent/instrumentation/tilt/instrumentation.rb
Defined Under Namespace
Instance Method Summary collapse
-
#create_filename_for_metric(file) ⇒ Object
Sinatra uses #caller_locations for the file name in Tilt (unlike Rails/Rack) So here we are only grabbing the file name and name of directory it is in.
- #metric_name(klass, file) ⇒ Object
- #render_with_tracing(*args, &block) ⇒ Object
Instance Method Details
#create_filename_for_metric(file) ⇒ Object
Sinatra uses #caller_locations for the file name in Tilt (unlike Rails/Rack) So here we are only grabbing the file name and name of directory it is in
15 16 17 18 19 20 21 |
# File 'lib/new_relic/agent/instrumentation/tilt/instrumentation.rb', line 15 def create_filename_for_metric(file) return file unless defined?(::Sinatra) && defined?(::Sinatra::Base) file.split('/')[-2..-1].join('/') rescue NoMethodError file end |
#metric_name(klass, file) ⇒ Object
9 10 11 |
# File 'lib/new_relic/agent/instrumentation/tilt/instrumentation.rb', line 9 def metric_name(klass, file) "View/#{klass}/#{file}/Rendering" end |
#render_with_tracing(*args, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/new_relic/agent/instrumentation/tilt/instrumentation.rb', line 23 def render_with_tracing(*args, &block) begin finishable = Tracer.start_segment( name: metric_name(self.class, create_filename_for_metric(self.file)) ) begin yield rescue => error NewRelic::Agent.notice_error(error) raise end ensure # The following line needs else branch coverage finishable.finish if finishable # rubocop:disable Style/SafeNavigation end end |