Module: ScoutRailsProxy::Instruments::SinatraInstruments

Defined in:
lib/scout_rails_proxy/instruments/sinatra_instruments.rb

Instance Method Summary collapse

Instance Method Details

#route_eval_with_scout_instruments(&blockarg) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/scout_rails_proxy/instruments/sinatra_instruments.rb', line 3

def route_eval_with_scout_instruments(&blockarg)
  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 blockarg.equal? block
        name = pattern.source
      end
    end
  end
  name.gsub!(%r{^[/^]*(.*?)[/\$\?]*$}, '\1')
  name = 'root' if name.empty?
  name = @request.request_method + ' ' + name if @request && @request.respond_to?(:request_method)      
  scout_controller_action = "Controller/Sinatra/#{name}"
  self.class.trace(scout_controller_action, :uri => @request.path_info) do
    route_eval_without_scout_instruments(&blockarg)    
  end
end