Skip to content

Commit

Permalink
Added configuration option to ignore specific person exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
miloops committed Dec 23, 2013
1 parent 7d2f23b commit 294ff03
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/rollbar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def configuration
# `rollbar_person_data`
def report_exception(exception, request_data = nil, person_data = nil)
return 'disabled' unless configuration.enabled
return 'ignored' if ignored?(exception)
return 'ignored' if ignored?(exception) || (person_data.present? && configuration.ignored_person_ids.include?(person_data[Rollbar.configuration.person_id_method.to_sym]))

data = exception_data(exception, filtered_level(exception))
if request_data
Expand Down Expand Up @@ -340,12 +340,12 @@ def build_payload(data)

def base_data(level = 'error')
config = configuration

environment = config.environment
if environment.nil? || environment.empty?
environment = 'unspecified'
end

data = {
:timestamp => Time.now.to_i,
:environment => environment,
Expand Down
2 changes: 2 additions & 0 deletions lib/rollbar/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Configuration
attr_accessor :use_eventmachine
attr_accessor :web_base
attr_accessor :write_to_file
attr_accessor :ignored_person_ids

attr_reader :project_gem_paths

Expand Down Expand Up @@ -57,6 +58,7 @@ def initialize
@use_eventmachine = false
@web_base = DEFAULT_WEB_BASE
@write_to_file = false
@ignored_person_ids = []
end

def use_sidekiq(options = {})
Expand Down
19 changes: 18 additions & 1 deletion spec/rollbar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@
end
end

it 'should ignore ignored users' do
Rollbar.configure do |config|
config.ignored_person_ids += [1]
end

logger_mock.should_not_receive(:info)
logger_mock.should_not_receive(:warn)
logger_mock.should_not_receive(:error)

person_data = {
:id => 1,
:username => "test",
:email => "test@example.com"
}
Rollbar.report_exception(@exception, {}, person_data)
end

it 'should allow callables to set exception filtered level' do
callable_mock = double
saved_filters = Rollbar.configuration.exception_level_filters
Expand Down Expand Up @@ -677,7 +694,7 @@ class DummyClass
@dummy_class = DummyClass.new
@dummy_class.extend(Rollbar::RequestDataExtractor)
end

context "rollbar_headers" do
it "should not include cookies" do
env = {"HTTP_USER_AGENT" => "test", "HTTP_COOKIE" => "cookie"}
Expand Down

0 comments on commit 294ff03

Please sign in to comment.