Class: Opbeat::Rack
- Inherits:
-
Object
- Object
- Opbeat::Rack
- Defined in:
- lib/opbeat/rack.rb
Overview
Middleware for Rack applications. Any errors raised by the upstream application will be delivered to Opbeat and re-raised.
Synopsis:
require 'rack'
require 'opbeat'
Opbeat.configure do |config|
config.server = 'http://my_dsn'
end
app = Rack::Builder.app do
use Opbeat::Rack
run lambda { |env| raise "Rack down" }
end
Use a standard Opbeat.configure call to configure your server credentials.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
21 22 23 |
# File 'lib/opbeat/rack.rb', line 21 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/opbeat/rack.rb', line 25 def call(env) begin response = @app.call(env) rescue Error => e raise # Don't capture Opbeat errors rescue Exception => e evt = Event.capture_rack_exception(e, env) Opbeat.send(evt) raise end error = env['rack.exception'] || env['sinatra.error'] if error evt = Event.capture_rack_exception(error, env) Opbeat.send(evt) if evt end response end |