Module: NewRelic::Agent::Instrumentation::Sinatra
- Includes:
- ControllerInstrumentation
- Defined in:
- lib/new_relic/agent/instrumentation/sinatra.rb
Overview
NewRelic instrumentation for Sinatra applications. Sinatra actions will appear in the UI similar to controller actions, and have breakdown charts and transaction traces.
The actions in the UI will correspond to the pattern expression used to match them. HTTP operations are not distinguished. Multiple matches will all be tracked as separate actions.
Constant Summary
Constants included from QueueTime
QueueTime::ALL_MIDDLEWARE_METRIC, QueueTime::ALL_QUEUE_METRIC, QueueTime::ALL_SERVER_METRIC, QueueTime::ALT_QUEUE_HEADER, QueueTime::APP_HEADER, QueueTime::HEADER_REGEX, QueueTime::HEROKU_QUEUE_HEADER, QueueTime::MAIN_HEADER, QueueTime::MIDDLEWARE_HEADER, QueueTime::MIDDLEWARE_METRIC, QueueTime::QUEUE_HEADER, QueueTime::SERVER_METRIC
Instance Method Summary collapse
Methods included from ControllerInstrumentation
included, #newrelic_metric_path, #perform_action_with_newrelic_trace
Methods included from QueueTime
Instance Method Details
#route_eval_with_newrelic(&block_arg) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/new_relic/agent/instrumentation/sinatra.rb', line 36 def route_eval_with_newrelic(&block_arg) path = unescape(@request.path_info) name = path # Go through each route and look for a match if routes = self.class.routes[@request.request_method] routes.detect do |pattern, keys, conditions, block| if block_arg.equal? block name = pattern.source end end end # strip off leading ^ and / chars and trailing $ and / name.gsub!(%r{^[/^]*(.*?)[/\$\?]*$}, '\1') name = 'root' if name.empty? name = @request.request_method + ' ' + name if @request && @request.respond_to?(:request_method) perform_action_with_newrelic_trace(:category => :sinatra, :name => name, :params => @request.params) do route_eval_without_newrelic(&block_arg) end end |