Grape
Grape applications are officially supported. Instrumenting Grape applications requires some manual setup. Follow the installation steps in AppSignal, starting by clicking 'Add app' on the accounts screen.
Installation
After installing and configuring the AppSignal gem, add the AppSignal integration after the Grape app is loaded.
The Grape integration is required from the AppSignal Ruby gem, and the EventHandler instrumentation and instrumentation middleware are added in the following code examples.
The next step is to add the AppSignal middleware to the application's base API class. It will report any unhandled exceptions from the application.
Legacy installation
Applications using AppSignal for Ruby gem 3.11 or older, follow these steps to install AppSignal in Grape applications.
The Grape integration is required from the AppSignal Ruby gem, and the EventHandler instrumentation and instrumentation middleware are added in the following code examples.
The next step is to add the AppSignal middleware to the application's base API class. It will report any unhandled exceptions from the application.
Mounted Grape apps
Mounting Grape applications on Ruby on Rails applications is supported. The Ruby gem needs to be a recent version to properly instrument requests for mounted Grape apps.
Ignoring errors
To ignore a specific Grape error, set the grape.skip_appsignal_error
flag in the request environment. Setting this flag to true
will instruct AppSignal not to report any errors during the request.
Use this flag only if you need to dynamically ignore errors from a Grape application. Specify error classes in the ignore_errors
option to ignore them for the entire application. For more information on muting notifications for specific errors see our notification settings documentation.
Reporting errors from rescue_from
If an error is rescued in the app using rescue_from,
AppSignal will not receive and track it. To still report the error, call Appsignal.report_error
in the rescue_from
block. (Use the Appsignal.set_error
helper when using Ruby gem version 3 or older.)