Is your application using a combination of Rails, Grape, Hanami, Padrino or Sinatra? Follow our guide for instrumenting multiple Rack applications.
Installation
After installing the AppSignal gem, add the AppSignal integration after requiringhanami/boot in the config.ru file.
Exception handling
Hanami doesn’t have any exception handling by default. The web server (like Puma or Unicorn) will show a basic “internal server error” page if an error occurs in the app. These unhandled exceptions will be reported to AppSignal automatically. The Hanami exception handling guide explains how to add custom exception handling to Hanami applications to render custom error pages. Handled exceptions will not be reported to AppSignal automatically. We recommend adding the following code to the application’s base Action class found inapp/action.rb to add exception handling for StandardError. This way, adding exception handling to every action class is unnecessary.
In the handle_standard_error method, configured by handle_exception, call the Appsignal.report_error helper to report the exception to AppSignal and not miss any errors reported by your app. (Use the Appsignal.set_error helper when using Ruby gem version 3 or older.)
Appsignal.report_error method to the Hanami exceptions you want to report, AppSignal will report these errors whenever they occur.
Span attributes
Collector mode only: this applies when AppSignal for Ruby runs in collector mode. It has no effect otherwise.
http.request.method— the request method.url.scheme,url.path, andurl.query— the address that was requested.http.response.status_code— the status your application responded with.
error.type, the class of the error.
Distributed tracing
Collector mode only: this applies when AppSignal for Ruby runs in collector mode. It has no effect otherwise.
traceparent request header continues the trace it names.
The request appears inside the calling service’s trace, under the request that caused it. You can follow a slow request from that service into this application without switching traces.
The HTTP clients AppSignal supports start the trace. A request without the header starts a new one.