Skip to content

Commit

Permalink
reset error filter in multiverse test
Browse files Browse the repository at this point in the history
  • Loading branch information
amhuntsman committed Jun 25, 2021
1 parent b2b3cab commit 2d85b31
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
12 changes: 10 additions & 2 deletions lib/new_relic/agent/error_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ def expected?(ex, status_code = nil)
@error_filter.expected?(ex, status_code)
end

def load_error_filters
@error_filter.load_all
end

def reset_error_filters
@error_filter.reset
end

# Checks the provided error against the error filter, if there
# is an error filter
def ignored_by_filter_proc?(error)
Expand Down Expand Up @@ -179,9 +187,9 @@ def increment_expected_error_count!(state, exception)

def skip_notice_error?(exception, status_code = nil)
disabled? ||
error_is_ignored?(exception, status_code) ||
exception.nil? ||
exception_tagged_with?(EXCEPTION_TAG_IVAR, exception)
exception_tagged_with?(EXCEPTION_TAG_IVAR, exception) ||
error_is_ignored?(exception, status_code)
end

# calls a method on an object, if it responds to it - used for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def test_ignores_notfound_errors_by_default
get '/ignored_boom'
assert_equal 404, last_response.status
assert_match %r{Sinatra doesn(’|’)t know this ditty\.}, last_response.body

errors = harvest_error_traces!
assert_equal(0, errors.size)
end
Expand Down
1 change: 0 additions & 1 deletion test/new_relic/agent/error_collector_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ def test_skip_notice_error_is_true_if_the_error_collector_is_disabled
def test_skip_notice_error_is_true_if_the_error_is_nil
error = nil
with_config(:'error_collector.enabled' => true) do
@error_collector.expects(:error_is_ignored?).with(error, nil).returns(false)
assert @error_collector.skip_notice_error?(error)
end
end
Expand Down
6 changes: 4 additions & 2 deletions test/new_relic/multiverse_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def setup_agent(opts = {}, &block)
# to clean up before a test too.
NewRelic::Agent.drop_buffered_data

NewRelic::Agent.instance.error_collector.load_error_filters

trigger_agent_reconnect(opts)
end

Expand All @@ -69,8 +71,8 @@ def teardown_agent
# Clear out lingering stats we didn't transmit
NewRelic::Agent.drop_buffered_data

# Clear the error collector's ignore_filter
NewRelic::Agent.instance.error_collector.instance_variable_set(:@ignore_filter, nil)
# Clear the error collector's error filters
NewRelic::Agent.instance.error_collector.reset_error_filters

# Clean up any thread-local variables starting with 'newrelic'
NewRelic::Agent::Tracer.clear_state
Expand Down

0 comments on commit 2d85b31

Please sign in to comment.