Catch exception in Rails and POST to a separate Rails app

Go To StackoverFlow.com

0

I am working on a dashboard app which shows the server status, site stats and more and I am looking to add Rails application exception tracking as well.

My main reason for wanting to create my own is basically because I want an integrated version which is just one page showing everything happening on my servers and apps.

The dashboard app is a Rails app which has an app_exceptions controller & model with the following: app_id environment host message user_agent.

Would it be possible to throw all exception messages (much like Airbrake, etc) to this Dashboard app?

2012-04-03 23:24
by Dean Perry


0

Just an update, I am now using the rails_exception_handler gem - https://github.com/Sharagoz/rails_exception_handler

With this I can POST to my Dashboard app very easily :)

2012-04-04 13:30
by Dean Perry


0

One way is to use the rescue_from in your application controller to call a method that POSTs to your dashboard API.

class ApplicationController < ActionController::Base
rescue_from Exception, :with => :postNotification    

rescue_from info

on your :with method definition, define a variable space and you can POST that passed var to your dashboard API, you could do analyzation / display on the dashboard side to give you the most playing room as far as what exception info you want to work with:

def postNotification(e)
   postToDashboardAPI(e)
end
2012-04-03 23:34
by franklin stine
It's that simple? Nice. How would I be able to collect & send the parameters such as the error type, the messages, etc - Dean Perry 2012-04-03 23:37
And you could post using Net::HTTP.post_for - franklin stine 2012-04-03 23:53
Oh cool. Will give it a go, thank - Dean Perry 2012-04-03 23:53