Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Using Airbrake in Rack apps

Kyrylo Silin edited this page Aug 24, 2016 · 5 revisions

END OF SUPPORT WARNING: On November 24, 2016 Airbrake v4 won't be supported anymore and this wiki will be deleted. Read more & discuss: https://github.com/airbrake/airbrake/issues/596

DEPRECATION WARNING: The information presented on this page is related to Airbrake v4 only. If you seek for information for Airbrake v5, please refer to our README!

In order to use airbrake in a non-Rails rack app, just load airbrake, configure your API key, and use the Airbrake::Rack middleware:

require 'rack'
require 'airbrake'

Airbrake.configure do |config|
  config.api_key = 'my_api_key'
  ## can also set the environment over here 
  config.environment_name = ENV['RACK_ENV'] || "development"
end

app = Rack::Builder.app do
  run lambda { |env| raise "Rack down" }
end
    
use Airbrake::Rack
run app