Provides a drop-in way of reporting errors to the Rollbar error aggregation service.
gem install rosette-integration-rollbar
Then, somewhere in your project:
require 'rosette/integrations/rollbar_integration'
This library is generally meant to be used with the Rosette internationalization platform. It provides a Rosette error reporter that can integrate into your Rosette config, as well as an integration for rosette-server that can report exceptions raised in API endpoints.
This is the primary way Rosette users should integrate Rollbar.
require 'rosette/integrations/rollbar_integration'
require 'rollbar' # add the rollbar gem to your Gemfile
notifier = Rollbar::Notifier.new.tap do |n|
n.access_token = '123abc'
end
rosette_config = Rosette.build_config do |config|
config.add_integration('rollbar') do |integration_config|
integration_config.set_rollbar_notifier(notifier)
end
end
Now that the integration has been configured, the Rosette error reporter will be set to an instance of Rosette::Integrations::RollbarIntegration::RollbarErrorReporter
, and can be used like any error reporter:
begin
raise StandardError, 'Something went wrong'
rescue => e
rosette_config.error_reporter.report_error(e)
end
If you've already added Rollbar integration to your Rosette config, creating a new instance of Rosette::Server::ApiV1
will automatically apply the Rollbar integration to your server instance.
# config.ru
require 'rosette/server'
server = Rosette::Server::ApiV1.new(rosette_config)
run server
Any errors generated by the API, including errors in API responses (expected errors) and un-rescued errors (unexpected errors), will now be reported to Rollbar.
You can disable the reporting of expected errors by setting the appropriate flag in the integration config:
Rosette.build_config do |config|
config.add_integration('rollbar') do |integration_config|
integration_config.should_log_expected_errors(false)
end
end
This project must be run under jRuby. It uses expert to manage java dependencies via Maven. Run bundle exec expert install
in the project root to download and install java dependencies.
bundle exec rake
or bundle exec rspec
should do the trick.
- Cameron C. Dutro: http://github.com/camertron