Skip to content

Commit

Permalink
added test for recording exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mcinbell committed Jun 16, 2023
1 parent 6b7eaa8 commit cbec0cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,19 @@
_(job_span.attributes['messaging.destination_kind']).must_equal 'queue'
_(job_span.attributes['messaging.operation']).must_equal 'process'
end

describe 'when worker raises exception' do
let(:worker_class) { ExceptionTestingJob }

it 'records exceptions' do

_(-> { Shoryuken::Processor.process(queue_name, sqs_msg) }).must_raise(RuntimeError)

ev = job_span.events
_(ev[0].attributes['exception.type']).must_equal('RuntimeError')
_(ev[0].attributes['exception.message']).must_equal('a little hell')
_(ev[0].attributes['exception.stacktrace']).wont_be_nil
end
end
end
end
14 changes: 7 additions & 7 deletions instrumentation/shoryuken/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def perform(sqs_msg, payload); end
# end
# end

# class ExceptionTestingJob
# include Shoryuken::Worker
# shoryuken_options body_parser: JSON, queue: 'default', auto_delete: true
class ExceptionTestingJob
include Shoryuken::Worker
shoryuken_options body_parser: JSON, queue: 'default', auto_delete: true

# def perform(*args)
# raise 'a little hell'
# end
# end
def perform(*args)
raise 'a little hell'
end
end

module Shoryuken
module CLI
Expand Down

0 comments on commit cbec0cb

Please sign in to comment.