lib/newrelic-grape/instrument.rb in newrelic-grape-1.3.1 vs lib/newrelic-grape/instrument.rb in newrelic-grape-1.4.1
- old
+ new
@@ -1,6 +1,8 @@
+require 'new_relic/agent/instrumentation'
require 'new_relic/agent/instrumentation/controller_instrumentation'
+require 'grape'
module NewRelic
module Agent
module Instrumentation
class Grape < ::Grape::Middleware::Base
@@ -18,17 +20,24 @@
perform_action_with_newrelic_trace(trace_options) do
@app_response = @app.call(@env)
end
end
+ def route
+ env['api.endpoint'].routes.first
+ end
+
def request_path
- env['api.endpoint'].routes.first.route_path[1..-1].gsub("/", "-").sub(/\(\.:format\)\z/, "")
+ path = route.route_path[1..-1].gsub('/', '-')
+ path.sub!(/\(\.:format\)\z/, '')
+ route.route_version && path.sub!(':version', route.route_version)
+
+ path
end
def request_method
@newrelic_request.request_method
end
-
end
end
end
end