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

Remove obsolete exception_controller option #3243

Merged
merged 1 commit into from
Dec 7, 2023
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
12 changes: 0 additions & 12 deletions lib/datadog/tracing/contrib/action_pack/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ class Settings < Contrib::Configuration::Settings
o.default 1.0
end

# DEV-2.0: Breaking changes for removal.
option :exception_controller do |o|
o.after_set do |value|
if value
Datadog::Core.log_deprecation do
'The error controller is now automatically detected. '\
"Option `#{o.instance_variable_get(:@name)}` is no longer required and will be removed."
end
end
end
end

option :service_name
end
end
Expand Down
11 changes: 0 additions & 11 deletions lib/datadog/tracing/contrib/rails/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ def initialize(options = {})
option :request_queuing do |o|
o.default false
end
# DEV-2.0: Breaking changes for removal.
option :exception_controller do |o|
o.after_set do |value|
if value
Datadog::Core.log_deprecation do
'The error controller is now automatically detected. '\
"Option `#{o.instance_variable_get(:@name)}` is no longer required and will be removed."
end
end
end
end

option :middleware, default: true, type: :bool
option :middleware_names, default: false, type: :bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
request_exception: action_dispatch_exception
},
tracing_context: {},
exception_controller?: false,
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,330 +180,6 @@ def raise_exception
end
end
end

context 'when configure exception_controller with a constant' do
before do
Datadog.configure do |c|
c.tracing.instrument :rack
c.tracing.instrument :action_pack, exception_controller: exception_controller_class
end
end

context 'when given a request to test endpoint' do
it 'renders within TestController' do
get '/test'

expect(spans).to have(2).items

rack_span, controller_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('TestController#test')

expect(controller_span.parent_id).to eq(rack_span.id)
expect(controller_span.name).to eq('rails.action_controller')
expect(controller_span.resource).to eq('TestController#test')
expect(controller_span.get_tag('component')).to eq('action_pack')
expect(controller_span.get_tag('operation')).to eq('controller')
expect(controller_span.get_tag('rails.route.controller')).to eq('TestController')
expect(controller_span.get_tag('rails.route.action')).to eq('test')
end
end

context 'when given a request that raise exception' do
it 'renders the exception with error handler' do
get '/boom'

expect(spans).to have(3).items

rack_span, handle_err_span, controller_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('TestController#raise_exception')
expect(rack_span).to_not have_error

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
expect(handle_err_span).to_not have_error

expect(controller_span.parent_id).to eq(rack_span.id)
expect(controller_span.name).to eq('rails.action_controller')
expect(controller_span.resource).to eq('TestController#raise_exception')
expect(controller_span.get_tag('component')).to eq('action_pack')
expect(controller_span.get_tag('operation')).to eq('controller')
expect(controller_span.get_tag('rails.route.controller')).to eq('TestController')
expect(controller_span.get_tag('rails.route.action')).to eq('raise_exception')
expect(controller_span).to have_error
end
end

context 'when given a request to error handling endpoint' do
it 'renders within ErrorController' do
get '/error_handler'

expect(spans).to have(2).items

rack_span, handle_err_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('ErrorController#handle_error')

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
end
end

context 'when given a request to error handling endpoint with ActionDispatch exception' do
it 'renders within ErrorController and does not change trace resource' do
get '/error_handler', {}, 'action_dispatch.exception' => ArgumentError.new

expect(spans).to have(2).items

rack_span, handle_err_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('GET 200')

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
end
end
end

context 'when configure exception_controller with a string' do
before do
Datadog.configure do |c|
c.tracing.instrument :rack
c.tracing.instrument :action_pack, exception_controller: exception_controller_class.to_s
end
end

context 'when given a request to test endpoint' do
it 'renders within TestController' do
get '/test'

expect(spans).to have(2).items

rack_span, controller_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('TestController#test')

expect(controller_span.parent_id).to eq(rack_span.id)
expect(controller_span.name).to eq('rails.action_controller')
expect(controller_span.resource).to eq('TestController#test')
expect(controller_span.get_tag('component')).to eq('action_pack')
expect(controller_span.get_tag('operation')).to eq('controller')
expect(controller_span.get_tag('rails.route.controller')).to eq('TestController')
expect(controller_span.get_tag('rails.route.action')).to eq('test')
end
end

context 'when given a request that raise exception' do
it 'renders the exception with error handler' do
get '/boom'

expect(spans).to have(3).items

rack_span, handle_err_span, controller_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('TestController#raise_exception')
expect(rack_span).to_not have_error

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
expect(handle_err_span).to_not have_error

expect(controller_span.parent_id).to eq(rack_span.id)
expect(controller_span.name).to eq('rails.action_controller')
expect(controller_span.resource).to eq('TestController#raise_exception')
expect(controller_span.get_tag('component')).to eq('action_pack')
expect(controller_span.get_tag('operation')).to eq('controller')
expect(controller_span.get_tag('rails.route.controller')).to eq('TestController')
expect(controller_span.get_tag('rails.route.action')).to eq('raise_exception')
expect(controller_span).to have_error
end
end

context 'when given a request to error handling endpoint' do
it 'renders within ErrorController' do
get '/error_handler'

expect(spans).to have(2).items

rack_span, handle_err_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('ErrorController#handle_error')

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
end
end

context 'when given a request to error handling endpoint with ActionDispatch exception' do
it 'renders within ErrorController and does not change trace resource' do
get '/error_handler', {}, 'action_dispatch.exception' => ArgumentError.new

expect(spans).to have(2).items

rack_span, handle_err_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('GET 200')

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
end
end
end

context 'when configure exception_controller with a wrong string' do
before do
Datadog.configure do |c|
c.tracing.instrument :rack
c.tracing.instrument :action_pack, exception_controller: 'CannotFindThisConstant'
end
end

context 'when given a request to test endpoint' do
it 'renders within TestController' do
get '/test'

expect(spans).to have(2).items

rack_span, controller_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('TestController#test')

expect(controller_span.parent_id).to eq(rack_span.id)
expect(controller_span.name).to eq('rails.action_controller')
expect(controller_span.resource).to eq('TestController#test')
expect(controller_span.get_tag('component')).to eq('action_pack')
expect(controller_span.get_tag('operation')).to eq('controller')
expect(controller_span.get_tag('rails.route.controller')).to eq('TestController')
expect(controller_span.get_tag('rails.route.action')).to eq('test')
end
end

context 'when given a request that raise exception' do
it 'renders the exception with error handler' do
get '/boom'

expect(spans).to have(3).items

rack_span, handle_err_span, controller_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('TestController#raise_exception')
expect(rack_span).to_not have_error

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
expect(handle_err_span).to_not have_error

expect(controller_span.parent_id).to eq(rack_span.id)
expect(controller_span.name).to eq('rails.action_controller')
expect(controller_span.resource).to eq('TestController#raise_exception')
expect(controller_span.get_tag('component')).to eq('action_pack')
expect(controller_span.get_tag('operation')).to eq('controller')
expect(controller_span.get_tag('rails.route.controller')).to eq('TestController')
expect(controller_span.get_tag('rails.route.action')).to eq('raise_exception')
expect(controller_span).to have_error
end
end

context 'when given a request to error handling endpoint' do
it 'renders within ErrorController' do
get '/error_handler'

expect(spans).to have(2).items

rack_span, handle_err_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('ErrorController#handle_error')

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
end
end

context 'when given a request to error handling endpoint with ActionDispatch exception' do
it 'renders within ErrorController and does not change trace resource' do
get '/error_handler', {}, 'action_dispatch.exception' => ArgumentError.new

expect(spans).to have(2).items

rack_span, handle_err_span = spans

expect(rack_span).to be_root_span
expect(rack_span.name).to eq('rack.request')
expect(rack_span.resource).to eq('GET 200')

expect(handle_err_span.parent_id).to eq(rack_span.id)
expect(handle_err_span.name).to eq('rails.action_controller')
expect(handle_err_span.resource).to eq('ErrorController#handle_error')
expect(handle_err_span.get_tag('component')).to eq('action_pack')
expect(handle_err_span.get_tag('operation')).to eq('controller')
expect(handle_err_span.get_tag('rails.route.controller')).to eq('ErrorController')
expect(handle_err_span.get_tag('rails.route.action')).to eq('handle_error')
end
end
end
end
end
end
Expand Down

This file was deleted.

Loading
Loading