Skip to content

Commit

Permalink
revert breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
mabdinur committed Jul 19, 2024
1 parent 2f089cd commit dcda9d0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
8 changes: 8 additions & 0 deletions lib/datadog/tracing/metadata/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 13 additions & 11 deletions spec/datadog/tracing/metadata/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dcda9d0

Please sign in to comment.