Skip to content

Commit

Permalink
Merge pull request #3796 from DataDog/munir/revert-api-breaking-change
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc authored Jul 29, 2024
2 parents 8943001 + dcda9d0 commit 47f12db
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 47f12db

Please sign in to comment.