Adding Custom Data to Error Notifications with Middleware in Rails 3.2
I would like to add a custom bugsnag tab for all notifications generated by my rails app.
I can't use: before_bugsnag_notify because errors are sometimes generated by models called from repeated background jobs.
So I decided to use middleware and I have some problems here:
so I went through this guide here: https://bugsnag.com/docs/notifiers/ruby#bugsnag-middleware
and added my middleware in app / middleware like this:
class CustomMiddleware
def initialize(bugsnag)
@bugsnag = bugsnag
end
def call(notification)
puts "doing something"
@bugsnag.call(notification)
end
end
The config file for bugsnag looks like this:
in config / initializers / bugsnag.rb:
Bugsnag.configure do |config|
config.api_key = "#{ENV['BUGSNAG_API_KEY']}"
config.middleware.use "CustomMiddleWare"
end
Eventually, I would like to add a tab using the add_tab () method before @ bugsnag.call (), but now I keep running with an error that I cannot fix:
** [Bugsnag] Bugsnag middleware error: undefined method `new' for "CustomMiddleWare":String
Any ideas?
Edit: I had to put the method name on a string because of this: Where do you put the rack middleware files and require?
source to share
No one has answered this question yet
See similar questions:
or similar: