36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/scout_apm/instruments/grape.rb', line 36
def run_with_scout_instruments(*args)
request = ::Grape::Request.new(env || args.first)
req = ScoutApm::RequestManager.lookup
path = ScoutApm::Agent.instance.context.config.value("uri_reporting") == 'path' ? request.path : request.fullpath
req.annotate_request(:uri => path)
req.context.add_user(:ip => request.ip) rescue nil
req.(request.)
begin
name = ["Grape",
self.options[:method].first,
self.options[:for].to_s,
self.namespace.sub(%r{\A/}, ''), self.options[:path].first,
].compact.map{ |n| n.to_s }.join("/")
rescue => e
logger.info("Error getting Grape Endpoint Name. Error: #{e.message}. Options: #{self.options.inspect}")
name = "Grape/Unknown"
end
req.start_layer( ScoutApm::Layer.new("Controller", name) )
begin
run_without_scout_instruments(*args)
rescue
req.error!
raise
ensure
req.stop_layer
end
end
|