|
21 | 21 | }
|
22 | 22 | end
|
23 | 23 |
|
24 |
| - it "tracks error on a new transaction" do |
25 |
| - described_class.new.call(exception, job_context) |
26 |
| - |
27 |
| - transaction_hash = last_transaction.to_h |
28 |
| - expect(transaction_hash["error"]).to include( |
29 |
| - "name" => "ExampleStandardError", |
30 |
| - "message" => "uh oh", |
31 |
| - "backtrace" => kind_of(String) |
32 |
| - ) |
33 |
| - expect(transaction_hash["sample_data"]).to include( |
34 |
| - "params" => { |
35 |
| - "jobstr" => "{ bad json }" |
36 |
| - } |
37 |
| - ) |
38 |
| - expect(transaction_hash["metadata"]).to include( |
39 |
| - "sidekiq_error" => "Sidekiq internal error!" |
40 |
| - ) |
| 24 | + context "when error is an internal error" do |
| 25 | + it "tracks error on a new transaction" do |
| 26 | + expect do |
| 27 | + described_class.new.call(exception, job_context) |
| 28 | + end.to(change { created_transactions.count }.by(1)) |
| 29 | + |
| 30 | + transaction_hash = last_transaction.to_h |
| 31 | + expect(transaction_hash).to include( |
| 32 | + "action" => "SidekiqInternal", |
| 33 | + "error" => hash_including( |
| 34 | + "name" => "ExampleStandardError", |
| 35 | + "message" => "uh oh", |
| 36 | + "backtrace" => kind_of(String) |
| 37 | + ) |
| 38 | + ) |
| 39 | + expect(transaction_hash["sample_data"]).to include( |
| 40 | + "params" => { |
| 41 | + "jobstr" => "{ bad json }" |
| 42 | + } |
| 43 | + ) |
| 44 | + expect(transaction_hash["metadata"]).to include( |
| 45 | + "sidekiq_error" => "Sidekiq internal error!" |
| 46 | + ) |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + context "when error is a job error" do |
| 51 | + let(:transaction) { http_request_transaction } |
| 52 | + before do |
| 53 | + transaction.set_action("existing transaction action") |
| 54 | + set_current_transaction(transaction) |
| 55 | + end |
| 56 | + |
| 57 | + it "tracks error on the existing transaction" do |
| 58 | + expect do |
| 59 | + described_class.new.call(exception, job_context) |
| 60 | + end.to_not(change { created_transactions.count }) |
| 61 | + |
| 62 | + transaction_hash = last_transaction.to_h |
| 63 | + expect(transaction_hash).to include( |
| 64 | + "action" => "existing transaction action", |
| 65 | + "error" => hash_including( |
| 66 | + "name" => "ExampleStandardError", |
| 67 | + "message" => "uh oh", |
| 68 | + "backtrace" => kind_of(String) |
| 69 | + ) |
| 70 | + ) |
| 71 | + end |
41 | 72 | end
|
42 | 73 | end
|
43 | 74 | end
|
|
0 commit comments