Grape instrumentation

As of version 3.10.0, the New Relic Ruby agent has built-in support for instrumenting Grape applications. The minimum Grape version that the Ruby agent will instrument automatically is 0.2.0.

Usage with third-party gem

The newrelic-grape is a third-party gem that provides Grape instrumentation support as an add-on to the Ruby agent. If the newrelic-grape gem is detected, the Ruby agent will not install New Relic's built-in Grape instrumentation, and a log message like this will appear at startup:

 INFO : Not installing New Relic supported Grape instrumentation because the third party newrelic-grape gem is present 

If you want to use New Relic's official (built-in) Grape instrumentation, remove the newrelic-grape gem. (The transaction names captured by New Relic's official Grape instrumentation contain more detail. For example, they include the API version even if you are using non-path-based versioning.) However, if you want to continue using the newrelic-grape instrumentation to preserve your existing transaction names, you may safely ignore this message.

Parameter capture with Grape

Using the capture_params configuration setting, you can configure the Ruby agent to automatically capture request parameters on incoming API requests serviced by Grape. This will attach the captured parameters to transaction traces and traced errors.

Note: If you are using Grape's declared parameters, the captured parameters will be the raw params before passing through the declared(params) helper.

Grape and cross application tracing

New Relic's Cross Application Tracing feature allows you to better understand calls between multiple applications that are all monitored with New Relic agents on the same account. This is usefule, for example, to see which other applications are making calls into your Grape API. Cross application tracing should work automatically for any Rack application, including Grape apps.

Exception: If you have explicitly set the disable_middleware_instrumentation configuration setting to disable instrumention of third-party Rack middlewares, you will need to manually include the AgentHooks middleware.

For more help

Join the discussion about Ruby in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.