class NewRelic::Agent::Instrumentation::Grape

Public Instance Methods

call!(env) click to toggle source
# File lib/newrelic-grape/instrument.rb, line 11
def call!(env)
  @env = env
  @newrelic_request = ::Rack::Request.new(env)
  trace_options = {
    category: :rack,
    path: "#{request_method} #{request_path}",
    request: @newrelic_request,
    params: @newrelic_request.params
  }
  perform_action_with_newrelic_trace(trace_options) do
    @app_response = @app.call(@env)
  end
end
request_method() click to toggle source
# File lib/newrelic-grape/instrument.rb, line 37
def request_method
  @newrelic_request.request_method
end
request_path() click to toggle source
# File lib/newrelic-grape/instrument.rb, line 29
def request_path
  path = route.route_path[1..-1].tr('/', '-')
  path.sub!(/\(\.:format\)\z/, '')
  route.route_version && path.sub!(':version', route.route_version)

  path
end
route() click to toggle source
# File lib/newrelic-grape/instrument.rb, line 25
def route
  env['api.endpoint'].routes.first
end