Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow config to not inject the exception hooks #169

Merged
merged 3 commits into from
Nov 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $ heroku config:add ROLLBAR_ACCESS_TOKEN=POST_SERVER_ITEM_ACCESS_TOKEN

That's all you need to use Rollbar with Rails.

### If not using Rails
### If using Rack

Be sure to initialize Rollbar with your access token somewhere during startup:

Expand All @@ -67,6 +67,28 @@ end
<!-- RemoveNextIfProject -->
Be sure to replace ```POST_SERVER_ITEM_ACCESS_TOKEN``` with your project's ```post_server_item``` access token, which you can find in the Rollbar.com interface.

This monkey patches `Rack::Builder` to work with Rollbar automatically.

For more control, disable the monkey patch in the rollbar configuration:

```ruby
Rollbar.configure do |config|
config.disable_monkey_patch = true
# other configuration settings
# ...
end
```

Then mount the middleware in your app, like:

```ruby
class MyApp < Sinatra::Base
use Rollbar::Middleware::Sinatra
# other middleware/etc
# ...
end
```

## Test your installation

To confirm that it worked, run:
Expand Down
1 change: 1 addition & 0 deletions lib/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ def configuration
end

def require_hooks
return if configuration.disable_monkey_patch
wrap_delayed_worker

require 'rollbar/sidekiq' if defined?(Sidekiq)
Expand Down
2 changes: 2 additions & 0 deletions lib/rollbar/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Configuration
attr_accessor :custom_data_method
attr_accessor :delayed_job_enabled
attr_accessor :default_logger
attr_accessor :disable_monkey_patch
attr_accessor :dj_threshold
attr_accessor :enabled
attr_accessor :endpoint
Expand Down Expand Up @@ -47,6 +48,7 @@ def initialize
@custom_data_method = nil
@default_logger = lambda { Logger.new(STDERR) }
@delayed_job_enabled = true
@disable_monkey_patch = false
@dj_threshold = 0
@enabled = nil # set to true when configure is called
@endpoint = DEFAULT_ENDPOINT
Expand Down