Class: NewRelic::Agent::Instrumentation::Grape

Inherits:
Grape::Middleware::Base
  • Object
show all
Includes:
ControllerInstrumentation
Defined in:
lib/newrelic-grape/instrument.rb

Instance Method Summary collapse

Instance Method Details

#call!(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/newrelic-grape/instrument.rb', line 10

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_methodObject



28
29
30
# File 'lib/newrelic-grape/instrument.rb', line 28

def request_method
  @newrelic_request.request_method
end

#request_pathObject



24
25
26
# File 'lib/newrelic-grape/instrument.rb', line 24

def request_path
  env['api.endpoint'].routes.first.route_path[1..-1].gsub("/", "-").sub(/\(\.:format\)\z/, "")
end