diff --git a/lib/datadog/tracing/metadata/errors.rb b/lib/datadog/tracing/metadata/errors.rb index 22773c60328..2fd8129b2ff 100644 --- a/lib/datadog/tracing/metadata/errors.rb +++ b/lib/datadog/tracing/metadata/errors.rb @@ -10,6 +10,14 @@ module Metadata # Adds error tagging behavior # @public_api module Errors + def set_error(e) + Datadog::Core.log_deprecation do + 'Errors.set_error(..) is deprecated. ' \ + 'Use Errors.set_error_tags(..) instead.' + end + set_error_tags(e) + end + # Mark the span with the given error. def set_error_tags(e) e = Core::Error.build_from(e) diff --git a/spec/datadog/tracing/metadata/errors_spec.rb b/spec/datadog/tracing/metadata/errors_spec.rb index 1d9d61ca09a..7ac7392a500 100644 --- a/spec/datadog/tracing/metadata/errors_spec.rb +++ b/spec/datadog/tracing/metadata/errors_spec.rb @@ -12,21 +12,23 @@ end end - describe '#set_error_tags' do - subject(:set_error_tags) { test_object.set_error_tags(error) } + Array(['set_error', 'set_error_tags']) do |method_name| + describe "##{method_name}" do + subject(:error_setter) { test_object.send(method_name) } - let(:error) { RuntimeError.new('oops') } - let(:backtrace) { %w[method1 method2 method3] } + let(:error) { RuntimeError.new('oops') } + let(:backtrace) { %w[method1 method2 method3] } - before { error.set_backtrace(backtrace) } + before { error.set_backtrace(backtrace) } - it do - set_error_tags + it do + error_setter - expect(test_object).to have_error_message('oops') - expect(test_object).to have_error_type('RuntimeError') - backtrace.each do |method| - expect(test_object).to have_error_stack(include(method)) + expect(test_object).to have_error_message('oops') + expect(test_object).to have_error_type('RuntimeError') + backtrace.each do |method| + expect(test_object).to have_error_stack(include(method)) + end end end end