Sha256: d6fddca74550703daee3a511d5c9ed7129e299d4af9c986c5f7ba9bf182457e6
Contents?: true
Size: 1.18 KB
Versions: 7
Compression:
Stored size: 1.18 KB
Contents
# encoding: utf-8 # This file is distributed under New Relic's license terms. # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. module NewRelic module Agent module Instrumentation module Tilt def metric_name(klass, file) "View/#{klass}/#{file}/Rendering" end # 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 def create_filename_for_metric(file) return file unless defined?(::Sinatra) && defined?(::Sinatra::Base) file.split('/')[-2..-1].join('/') rescue NoMethodError file end 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 finishable.finish if finishable end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems