Class: Wildsight::Rack::BottomMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/wildsight/rack/bottom_middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ BottomMiddleware

Returns a new instance of BottomMiddleware.



6
7
8
# File 'lib/wildsight/rack/bottom_middleware.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/wildsight/rack/bottom_middleware.rb', line 10

def call(env)
  context = Wildsight::Rack.detect_context(env)
  response = context.profiler.duration(:rails) { @app.call(env) }
  return response
rescue Exception => e
  context.event(:exception, extract(e))
  raise e
end

#extract(exception) ⇒ Object



19
20
21
22
23
# File 'lib/wildsight/rack/bottom_middleware.rb', line 19

def extract(exception)
  data = {:message => exception.message, :name => exception.class.name, :backtrace => exception.backtrace}
  data[:cause] = extract_exception(exception.cause) if exception.cause
  return data
end