Rack

To instrument Rack applications AppSignal provides an instrumentation middleware which can be added to any Rack application.

To integrate AppSignal in a Rack application we first need to load, configure and start AppSignal.

require 'appsignal'                           # Load AppSignal
 
Appsignal.config = Appsignal::Config.new(
  File.expand_path('../', __FILE__),          # Application root path
  'development',                              # Application environment
  :name => 'logbrowser'                       # Optional configuration hash
)
 
Appsignal.start                               # Start the AppSignal integration
Appsignal.start_logger                        # Start logger

Lastly we need to add the instrumentation middleware to the application.

use Appsignal::Rack::GenericInstrumentation

By default all HTTP requests/actions are grouped under the 'unknown' group. You can override this for an action by setting the route in the request environment.

env["appsignal.route"] = "GET /homepage"

Or by using the Appsignal.set_action helper method in your Rack endpoints.

Appsignal.set_action("GET /homepage")

For better insights it's recommended to add additional instrumentation to the Rack application.

Want to help us improve this documentation page?

Create a pull request

Need more help?

Contact us and speak directly with the engineers working on AppSignal. They will help you get set up, tweak your code and make sure you get the most out of using AppSignal.

Contact us

Start a trial - 30 days free

AppSignal is a great way to monitor your Ruby, Elixir & Node.js applications. Works great with Rails, Phoenix, Express and other frameworks, with support for background jobs too. Let's improve your apps together.

Start a trial