appsignal 3.7.2-java → 3.7.3-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c887bf7c363f20a6d2260f00680017ce0b4f6c5d5480c0401d67e30edaaee09
4
- data.tar.gz: 4d1a4a75650f1282237fb69427c9f98ba2328e0f45322d2b2d1b5748ab57edad
3
+ metadata.gz: 1406255ddad7d2b216e2ed8976e5ff57bb8288300d94eab92a1e16408853e49a
4
+ data.tar.gz: 73d42e3fc21d20f6d4b5e4e4606bcafcb7a084c05ecfca2200e6c3e2bbcefc97
5
5
  SHA512:
6
- metadata.gz: 744a2655357d08b84c73fb6afa741f6b946f2a34b42421b397a22ead89a0eb4bf3d970d2562c8055568efd460bc9ee1e8de8609ab254be748dcceeac0b5672b5
7
- data.tar.gz: 24f32b9e25ccfbf41613124213bf4a5280380442516ab1c18d64fe29335375d6d9b403a73ae43a6d3295a4324035e360ff5ae388f3c088a11da1152605eb02c0
6
+ metadata.gz: 5a290cfb9ab1e48b88c2bed47e195b33d8a45a9ccaa8d004960e617923304065528bf5e21b675d37008c736799e601d2b83b2042f537f7ec54a2c4dd4bd12fa2
7
+ data.tar.gz: 400074db43e66759d091b4623e000fb63a9e45365b813ede6935289c917778f0e91918de528d1b4dd2a200558884cb9d56a0032f9cfa66ce2047b0a647851081
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 3.7.3
4
+
5
+ _Published on 2024-05-08._
6
+
7
+ ### Added
8
+
9
+ - [28a36ba1](https://github.com/appsignal/appsignal-ruby/commit/28a36ba17c236cf3f2f4991f3ff224a98c76eec7) patch - Add option to `activejob_report_errors` option to only report errors when a job is discard by Active Job. In the example below the job is retried twice. If it fails with an error twice the job is discarded. If `activejob_report_errors` is set to `discard`, you will only get an error reported when the job is discarded. This new `discard` value only works for Active Job 7.1 and newer.
10
+
11
+
12
+ ```ruby
13
+ class ExampleJob < ActiveJob::Base
14
+ retry_on StandardError, :attempts => 2
15
+
16
+ # ...
17
+ end
18
+ ```
19
+ - [d6d233de](https://github.com/appsignal/appsignal-ruby/commit/d6d233de8d1dd6aa203924e66db0635287aaea7b) patch - Track Active Job executions per job. When a job is retried the "executions" metadata for Active Job jobs goes up by one for every retry. We now track this as the `executions` tag on the job sample.
20
+
3
21
  ## 3.7.2
4
22
 
5
23
  _Published on 2024-05-06._
data/Gemfile CHANGED
@@ -3,3 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
+
7
+ # Fix install issue for jruby on gem 3.1.8.
8
+ # No java stub is published.
9
+ gem "bigdecimal", "3.1.7" if RUBY_PLATFORM == "java"
@@ -1,8 +1,10 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  ruby_version = Gem::Version.new(RUBY_VERSION)
4
- if ruby_version < Gem::Version.new("2.3.0")
5
- gem 'rack', '~> 1.6'
6
- end
4
+ gem "rack", "~> 1.6" if ruby_version < Gem::Version.new("2.3.0")
7
5
 
8
- gemspec :path => '../'
6
+ # Fix install issue for jruby on gem 3.1.8.
7
+ # No java stub is published.
8
+ gem "bigdecimal", "3.1.7" if RUBY_PLATFORM == "java"
9
+
10
+ gemspec :path => "../"
@@ -1,6 +1,10 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'rails', '~> 6.0.0'
3
+ gem "rails", "~> 6.0.0"
4
4
  gem "sidekiq"
5
5
 
6
- gemspec :path => '../'
6
+ # Fix install issue for jruby on gem 3.1.8.
7
+ # No java stub is published.
8
+ gem "bigdecimal", "3.1.7" if RUBY_PLATFORM == "java"
9
+
10
+ gemspec :path => "../"
@@ -1,7 +1,11 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ gem "net-smtp", :require => false
3
4
  gem "rails", "~> 6.1.0"
4
- gem "net-smtp", require: false
5
5
  gem "sidekiq"
6
6
 
7
+ # Fix install issue for jruby on gem 3.1.8.
8
+ # No java stub is published.
9
+ gem "bigdecimal", "3.1.7" if RUBY_PLATFORM == "java"
10
+
7
11
  gemspec :path => "../"
@@ -1,7 +1,11 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem 'rails', "~> 7.0.1"
4
- gem "sidekiq"
3
+ gem "rails", "~> 7.0.1"
5
4
  gem "rake", "> 12.2"
5
+ gem "sidekiq"
6
+
7
+ # Fix install issue for jruby on gem 3.1.8.
8
+ # No java stub is published.
9
+ gem "bigdecimal", "3.1.7" if RUBY_PLATFORM == "java"
6
10
 
7
- gemspec :path => '../'
11
+ gemspec :path => "../"
@@ -4,4 +4,8 @@ gem "rails", "~> 7.1.0"
4
4
  gem "rake", "> 12.2"
5
5
  gem "sidekiq"
6
6
 
7
+ # Fix install issue for jruby on gem 3.1.8.
8
+ # No java stub is published.
9
+ gem "bigdecimal", "3.1.7" if RUBY_PLATFORM == "java"
10
+
7
11
  gemspec :path => "../"
@@ -558,6 +558,11 @@ module Appsignal
558
558
  config[:send_session_data] = !skip_session_data if send_session_data.nil?
559
559
  end
560
560
 
561
+ if config_hash[:activejob_report_errors] == "discard" &&
562
+ !Appsignal::Hooks::ActiveJobHook.version_7_1_or_higher?
563
+ config[:activejob_report_errors] = "all"
564
+ end
565
+
561
566
  config
562
567
  end
563
568
 
@@ -6,14 +6,38 @@ module Appsignal
6
6
  class ActiveJobHook < Appsignal::Hooks::Hook
7
7
  register :active_job
8
8
 
9
- def dependencies_present?
9
+ def self.version_7_1_or_higher?
10
+ @version_7_1_or_higher ||=
11
+ if dependencies_present?
12
+ major = ::ActiveJob::VERSION::MAJOR
13
+ minor = ::ActiveJob::VERSION::MINOR
14
+ major > 7 || (major == 7 && minor >= 1)
15
+ else
16
+ false
17
+ end
18
+ end
19
+
20
+ def self.dependencies_present?
10
21
  defined?(::ActiveJob)
11
22
  end
12
23
 
24
+ def dependencies_present?
25
+ self.class.dependencies_present?
26
+ end
27
+
13
28
  def install
14
29
  ActiveSupport.on_load(:active_job) do
15
30
  ::ActiveJob::Base
16
31
  .extend ::Appsignal::Hooks::ActiveJobHook::ActiveJobClassInstrumentation
32
+
33
+ return unless Appsignal::Hooks::ActiveJobHook.version_7_1_or_higher?
34
+
35
+ # Only works on Active Job 7.1 and newer
36
+ ::ActiveJob::Base.after_discard do |_job, exception|
37
+ next unless Appsignal.config[:activejob_report_errors] == "discard"
38
+
39
+ Appsignal::Transaction.current.set_error(exception)
40
+ end
17
41
  end
18
42
  end
19
43
 
@@ -86,7 +110,9 @@ module Appsignal
86
110
  private
87
111
 
88
112
  def transaction_set_error(transaction, exception)
89
- return if Appsignal.config[:activejob_report_errors] == "none"
113
+ # Only report errors when the config option is set to "all".
114
+ # To report errors on discard, see the `after_discard` callback.
115
+ return unless Appsignal.config[:activejob_report_errors] == "all"
90
116
 
91
117
  transaction.set_error(exception)
92
118
  end
@@ -136,6 +162,8 @@ module Appsignal
136
162
  tags[:queue] = queue if queue
137
163
  priority = job["priority"]
138
164
  tags[:priority] = priority if priority
165
+ executions = job["executions"]
166
+ tags[:executions] = executions.to_i + 1 if executions
139
167
  tags
140
168
  end
141
169
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "3.7.2"
4
+ VERSION = "3.7.3"
5
5
  end
@@ -559,6 +559,30 @@ describe Appsignal::Config do
559
559
  end
560
560
  end
561
561
  end
562
+
563
+ if DependencyHelper.rails_present?
564
+ require "active_job"
565
+
566
+ context "activejob_report_errors" do
567
+ let(:config_options) { { :activejob_report_errors => "discard" } }
568
+
569
+ if DependencyHelper.rails_version >= Gem::Version.new("7.1.0")
570
+ context "when Active Job >= 7.1 and 'discard'" do
571
+ it "does not override the activejob_report_errors value" do
572
+ expect(config[:activejob_report_errors]).to eq("discard")
573
+ expect(config.override_config[:activejob_report_errors]).to be_nil
574
+ end
575
+ end
576
+ else
577
+ context "when Active Job < 7.1 and 'discard'" do
578
+ it "sets activejob_report_errors to 'all'" do
579
+ expect(config[:activejob_report_errors]).to eq("all")
580
+ expect(config.override_config[:activejob_report_errors]).to eq("all")
581
+ end
582
+ end
583
+ end
584
+ end
585
+ end
562
586
  end
563
587
 
564
588
  describe "config keys" do
@@ -88,6 +88,14 @@ if DependencyHelper.active_job_present?
88
88
  end
89
89
  end
90
90
 
91
+ class ActiveJobErrorWithRetryTestJob < ActiveJob::Base
92
+ retry_on StandardError, :wait => 0.seconds, :attempts => 2
93
+
94
+ def perform
95
+ raise "uh oh"
96
+ end
97
+ end
98
+
91
99
  class ActiveJobCustomQueueTestJob < ActiveJob::Base
92
100
  queue_as :custom_queue
93
101
 
@@ -99,6 +107,7 @@ if DependencyHelper.active_job_present?
99
107
  after do
100
108
  Object.send(:remove_const, :ActiveJobTestJob)
101
109
  Object.send(:remove_const, :ActiveJobErrorTestJob)
110
+ Object.send(:remove_const, :ActiveJobErrorWithRetryTestJob)
102
111
  Object.send(:remove_const, :ActiveJobCustomQueueTestJob)
103
112
  end
104
113
 
@@ -107,7 +116,7 @@ if DependencyHelper.active_job_present?
107
116
  expect(Appsignal).to receive(:increment_counter)
108
117
  .with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
109
118
 
110
- perform_job(ActiveJobTestJob)
119
+ queue_job(ActiveJobTestJob)
111
120
 
112
121
  transaction = last_transaction
113
122
  transaction_hash = transaction.to_h
@@ -120,7 +129,8 @@ if DependencyHelper.active_job_present?
120
129
  "params" => [],
121
130
  "tags" => {
122
131
  "active_job_id" => kind_of(String),
123
- "queue" => queue
132
+ "queue" => queue,
133
+ "executions" => 1
124
134
  }
125
135
  )
126
136
  )
@@ -136,7 +146,7 @@ if DependencyHelper.active_job_present?
136
146
  tags = { :queue => "custom_queue" }
137
147
  expect(Appsignal).to receive(:increment_counter)
138
148
  .with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
139
- perform_job(ActiveJobCustomQueueTestJob)
149
+ queue_job(ActiveJobCustomQueueTestJob)
140
150
 
141
151
  transaction = last_transaction
142
152
  transaction_hash = transaction.to_h
@@ -170,7 +180,7 @@ if DependencyHelper.active_job_present?
170
180
  .with("active_job_queue_priority_job_count", 1, tags.merge(:priority => 10,
171
181
  :status => :processed))
172
182
 
173
- perform_job(ActiveJobPriorityTestJob)
183
+ queue_job(ActiveJobPriorityTestJob)
174
184
 
175
185
  transaction = last_transaction
176
186
  transaction_hash = transaction.to_h
@@ -193,7 +203,7 @@ if DependencyHelper.active_job_present?
193
203
  .with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
194
204
 
195
205
  expect do
196
- perform_job(ActiveJobErrorTestJob)
206
+ queue_job(ActiveJobErrorTestJob)
197
207
  end.to raise_error(RuntimeError, "uh oh")
198
208
 
199
209
  transaction = last_transaction
@@ -211,7 +221,8 @@ if DependencyHelper.active_job_present?
211
221
  "params" => [],
212
222
  "tags" => {
213
223
  "active_job_id" => kind_of(String),
214
- "queue" => queue
224
+ "queue" => queue,
225
+ "executions" => 1
215
226
  }
216
227
  )
217
228
  )
@@ -227,23 +238,76 @@ if DependencyHelper.active_job_present?
227
238
  Appsignal.config = project_fixture_config("production")
228
239
  Appsignal.config[:activejob_report_errors] = "none"
229
240
 
230
- # Other calls we're testing in another test
231
241
  allow(Appsignal).to receive(:increment_counter)
232
242
  tags = { :queue => queue }
233
243
  expect(Appsignal).to receive(:increment_counter)
234
244
  .with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
235
- expect(Appsignal).to receive(:increment_counter)
236
- .with("active_job_queue_job_count", 1, tags.merge(:status => :processed))
237
245
 
238
246
  expect do
239
- perform_job(ActiveJobErrorTestJob)
247
+ queue_job(ActiveJobErrorTestJob)
240
248
  end.to raise_error(RuntimeError, "uh oh")
241
249
 
242
250
  transaction = last_transaction
243
251
  transaction_hash = transaction.to_h
244
- expect(transaction_hash).to include(
245
- "error" => nil
246
- )
252
+ expect(transaction_hash).to include("error" => nil)
253
+ end
254
+ end
255
+
256
+ if DependencyHelper.rails_version >= Gem::Version.new("7.1.0")
257
+ context "with activejob_report_errors set to discard" do
258
+ before do
259
+ Appsignal.config = project_fixture_config("production")
260
+ Appsignal.config[:activejob_report_errors] = "discard"
261
+ end
262
+
263
+ it "does not report error on first failure" do
264
+ with_test_adapter do
265
+ # Prevent the job from being instantly retried so we can test
266
+ # what happens before it's retried
267
+ allow_any_instance_of(ActiveJobErrorWithRetryTestJob).to receive(:retry_job)
268
+
269
+ queue_job(ActiveJobErrorWithRetryTestJob)
270
+ end
271
+
272
+ transaction = last_transaction
273
+ transaction_hash = transaction.to_h
274
+ expect(transaction_hash).to include(
275
+ "error" => nil,
276
+ "sample_data" => hash_including(
277
+ "tags" => hash_including(
278
+ "executions" => 1
279
+ )
280
+ )
281
+ )
282
+ end
283
+
284
+ it "reports error when discarding the job" do
285
+ allow(Appsignal).to receive(:increment_counter)
286
+ tags = { :queue => queue }
287
+ expect(Appsignal).to receive(:increment_counter)
288
+ .with("active_job_queue_job_count", 1, tags.merge(:status => :failed))
289
+
290
+ with_test_adapter do
291
+ expect do
292
+ queue_job(ActiveJobErrorWithRetryTestJob)
293
+ end.to raise_error(RuntimeError, "uh oh")
294
+ end
295
+
296
+ transaction = last_transaction
297
+ transaction_hash = transaction.to_h
298
+ expect(transaction_hash).to include(
299
+ "error" => {
300
+ "name" => "RuntimeError",
301
+ "message" => "uh oh",
302
+ "backtrace" => kind_of(String)
303
+ },
304
+ "sample_data" => hash_including(
305
+ "tags" => hash_including(
306
+ "executions" => 2
307
+ )
308
+ )
309
+ )
310
+ end
247
311
  end
248
312
  end
249
313
 
@@ -276,7 +340,7 @@ if DependencyHelper.active_job_present?
276
340
  :status => :failed))
277
341
 
278
342
  expect do
279
- perform_job(ActiveJobErrorPriorityTestJob)
343
+ queue_job(ActiveJobErrorPriorityTestJob)
280
344
  end.to raise_error(RuntimeError, "uh oh")
281
345
 
282
346
  transaction = last_transaction
@@ -291,13 +355,31 @@ if DependencyHelper.active_job_present?
291
355
  end
292
356
  end
293
357
 
358
+ context "with retries" do
359
+ it "reports the number of retries as executions" do
360
+ with_test_adapter do
361
+ expect do
362
+ queue_job(ActiveJobErrorWithRetryTestJob)
363
+ end.to raise_error(RuntimeError, "uh oh")
364
+ end
365
+
366
+ transaction = last_transaction
367
+ transaction_hash = transaction.to_h
368
+ expect(transaction_hash).to include(
369
+ "sample_data" => hash_including(
370
+ "tags" => hash_including("executions" => 2)
371
+ )
372
+ )
373
+ end
374
+ end
375
+
294
376
  context "when wrapped in another transaction" do
295
377
  it "does not create a new transaction or close the currently open one" do
296
378
  current_transaction = background_job_transaction
297
379
  allow(current_transaction).to receive(:complete).and_call_original
298
380
  set_current_transaction current_transaction
299
381
 
300
- perform_job(ActiveJobTestJob)
382
+ queue_job(ActiveJobTestJob)
301
383
 
302
384
  expect(created_transactions.count).to eql(1)
303
385
  expect(current_transaction).to_not have_received(:complete)
@@ -316,7 +398,8 @@ if DependencyHelper.active_job_present?
316
398
  "params" => [],
317
399
  "tags" => {
318
400
  "active_job_id" => kind_of(String),
319
- "queue" => queue
401
+ "queue" => queue,
402
+ "executions" => 1
320
403
  }
321
404
  )
322
405
  )
@@ -333,7 +416,7 @@ if DependencyHelper.active_job_present?
333
416
  it "filters the configured params" do
334
417
  Appsignal.config = project_fixture_config("production")
335
418
  Appsignal.config[:filter_parameters] = ["foo"]
336
- perform_job(ActiveJobTestJob, method_given_args)
419
+ queue_job(ActiveJobTestJob, method_given_args)
337
420
 
338
421
  transaction = last_transaction
339
422
  transaction_hash = transaction.to_h
@@ -382,7 +465,7 @@ if DependencyHelper.active_job_present?
382
465
  end
383
466
 
384
467
  it "sets provider_job_id as tag" do
385
- perform_job(ProviderWrappedActiveJobTestJob)
468
+ queue_job(ProviderWrappedActiveJobTestJob)
386
469
 
387
470
  transaction = last_transaction
388
471
  transaction_hash = transaction.to_h
@@ -424,7 +507,7 @@ if DependencyHelper.active_job_present?
424
507
 
425
508
  it "sets queue time on transaction" do
426
509
  allow_any_instance_of(Appsignal::Transaction).to receive(:set_queue_start).and_call_original
427
- perform_job(ProviderWrappedActiveJobTestJob)
510
+ queue_job(ProviderWrappedActiveJobTestJob)
428
511
 
429
512
  transaction = last_transaction
430
513
  queue_time = Time.parse("2020-10-10T10:10:10Z")
@@ -459,7 +542,8 @@ if DependencyHelper.active_job_present?
459
542
  "deliver_now"] + active_job_args_wrapper,
460
543
  "tags" => {
461
544
  "active_job_id" => kind_of(String),
462
- "queue" => "mailers"
545
+ "queue" => "mailers",
546
+ "executions" => 1
463
547
  }
464
548
  )
465
549
  )
@@ -479,7 +563,8 @@ if DependencyHelper.active_job_present?
479
563
  "deliver_now"] + active_job_args_wrapper(:args => method_expected_args),
480
564
  "tags" => {
481
565
  "active_job_id" => kind_of(String),
482
- "queue" => "mailers"
566
+ "queue" => "mailers",
567
+ "executions" => 1
483
568
  }
484
569
  )
485
570
  )
@@ -503,7 +588,8 @@ if DependencyHelper.active_job_present?
503
588
  ] + active_job_args_wrapper(:params => parameterized_expected_args),
504
589
  "tags" => {
505
590
  "active_job_id" => kind_of(String),
506
- "queue" => "mailers"
591
+ "queue" => "mailers",
592
+ "executions" => 1
507
593
  }
508
594
  )
509
595
  )
@@ -544,7 +630,8 @@ if DependencyHelper.active_job_present?
544
630
  ],
545
631
  "tags" => {
546
632
  "active_job_id" => kind_of(String),
547
- "queue" => "mailers"
633
+ "queue" => "mailers",
634
+ "executions" => 1
548
635
  }
549
636
  )
550
637
  )
@@ -570,7 +657,8 @@ if DependencyHelper.active_job_present?
570
657
  ],
571
658
  "tags" => {
572
659
  "active_job_id" => kind_of(String),
573
- "queue" => "mailers"
660
+ "queue" => "mailers",
661
+ "executions" => 1
574
662
  }
575
663
  )
576
664
  )
@@ -598,7 +686,8 @@ if DependencyHelper.active_job_present?
598
686
  ],
599
687
  "tags" => {
600
688
  "active_job_id" => kind_of(String),
601
- "queue" => "mailers"
689
+ "queue" => "mailers",
690
+ "executions" => 1
602
691
  }
603
692
  )
604
693
  )
@@ -607,11 +696,21 @@ if DependencyHelper.active_job_present?
607
696
  end
608
697
  end
609
698
 
699
+ def with_test_adapter
700
+ ActiveJob::Base.queue_adapter = :test
701
+ ActiveJob::Base.queue_adapter.performed_jobs.clear
702
+ ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true
703
+ ActiveJob::Base.queue_adapter.perform_enqueued_at_jobs = true
704
+ yield
705
+ ensure
706
+ ActiveJob::Base.queue_adapter = :inline # Restore to default
707
+ end
708
+
610
709
  def perform_active_job(&block)
611
710
  Timecop.freeze(time, &block)
612
711
  end
613
712
 
614
- def perform_job(job_class, args = nil)
713
+ def queue_job(job_class, args = nil)
615
714
  perform_active_job do
616
715
  if args
617
716
  job_class.perform_later(args)
@@ -17,7 +17,7 @@ describe Appsignal::Hooks::ResqueHook do
17
17
 
18
18
  if DependencyHelper.resque_present?
19
19
  describe "#install" do
20
- def perform_job(klass, options = {})
20
+ def perform_rescue_job(klass, options = {})
21
21
  payload = { "class" => klass.to_s }.merge(options)
22
22
  job = ::Resque::Job.new(queue, payload)
23
23
  keep_transactions { job.perform }
@@ -50,7 +50,7 @@ describe Appsignal::Hooks::ResqueHook do
50
50
  end
51
51
 
52
52
  it "tracks a transaction on perform" do
53
- perform_job(ResqueTestJob)
53
+ perform_rescue_job(ResqueTestJob)
54
54
 
55
55
  transaction = last_transaction
56
56
  transaction_hash = transaction.to_h
@@ -72,7 +72,7 @@ describe Appsignal::Hooks::ResqueHook do
72
72
  context "with error" do
73
73
  it "tracks the error on the transaction" do
74
74
  expect do
75
- perform_job(ResqueErrorTestJob)
75
+ perform_rescue_job(ResqueErrorTestJob)
76
76
  end.to raise_error(RuntimeError, "resque job error")
77
77
 
78
78
  transaction = last_transaction
@@ -102,7 +102,7 @@ describe Appsignal::Hooks::ResqueHook do
102
102
  end
103
103
 
104
104
  it "filters out configured arguments" do
105
- perform_job(
105
+ perform_rescue_job(
106
106
  ResqueTestJob,
107
107
  "args" => [
108
108
  "foo",
@@ -161,7 +161,7 @@ describe Appsignal::Hooks::ResqueHook do
161
161
  after { Object.send(:remove_const, :ActiveJobMock) }
162
162
 
163
163
  it "does not set arguments but lets the ActiveJob integration handle it" do
164
- perform_job(
164
+ perform_rescue_job(
165
165
  ResqueTestJob,
166
166
  "class" => "ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper",
167
167
  "args" => [
@@ -10,7 +10,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
10
10
  before(:context) { start_agent }
11
11
  around { |example| keep_transactions { example.run } }
12
12
 
13
- def perform_job(&block)
13
+ def perform_shoryuken_job(&block)
14
14
  block ||= lambda {}
15
15
  Timecop.freeze(Time.parse(time)) do
16
16
  Appsignal::Hooks::ShoryukenMiddleware.new.call(
@@ -34,7 +34,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
34
34
 
35
35
  it "wraps the job in a transaction with the correct params" do
36
36
  allow_any_instance_of(Appsignal::Transaction).to receive(:set_queue_start).and_call_original
37
- expect { perform_job }.to change { created_transactions.length }.by(1)
37
+ expect { perform_shoryuken_job }.to change { created_transactions.length }.by(1)
38
38
 
39
39
  transaction = last_transaction
40
40
  expect(transaction).to be_completed
@@ -80,7 +80,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
80
80
  end
81
81
 
82
82
  it "filters selected arguments" do
83
- perform_job
83
+ perform_shoryuken_job
84
84
 
85
85
  transaction_hash = last_transaction.to_h
86
86
  expect(transaction_hash["sample_data"]).to include(
@@ -94,7 +94,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
94
94
  let(:body) { "foo bar" }
95
95
 
96
96
  it "handles string arguments" do
97
- perform_job
97
+ perform_shoryuken_job
98
98
 
99
99
  transaction_hash = last_transaction.to_h
100
100
  expect(transaction_hash["sample_data"]).to include(
@@ -107,7 +107,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
107
107
  let(:body) { 1 }
108
108
 
109
109
  it "handles primitive types as arguments" do
110
- perform_job
110
+ perform_shoryuken_job
111
111
 
112
112
  transaction_hash = last_transaction.to_h
113
113
  expect(transaction_hash["sample_data"]).to include(
@@ -121,7 +121,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
121
121
  it "sets the exception on the transaction" do
122
122
  expect do
123
123
  expect do
124
- perform_job { raise ExampleException, "error message" }
124
+ perform_shoryuken_job { raise ExampleException, "error message" }
125
125
  end.to raise_error(ExampleException)
126
126
  end.to change { created_transactions.length }.by(1)
127
127
 
@@ -167,7 +167,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
167
167
  it "creates a transaction for the batch" do
168
168
  allow_any_instance_of(Appsignal::Transaction).to receive(:set_queue_start).and_call_original
169
169
  expect do
170
- perform_job {} # rubocop:disable Lint/EmptyBlock
170
+ perform_shoryuken_job {} # rubocop:disable Lint/EmptyBlock
171
171
  end.to change { created_transactions.length }.by(1)
172
172
 
173
173
  transaction = last_transaction
@@ -43,14 +43,14 @@ if DependencyHelper.que_present?
43
43
  end
44
44
  around { |example| keep_transactions { example.run } }
45
45
 
46
- def perform_job(job)
46
+ def perform_que_job(job)
47
47
  job._run
48
48
  end
49
49
 
50
50
  context "success" do
51
51
  it "creates a transaction for a job" do
52
52
  expect do
53
- perform_job(instance)
53
+ perform_que_job(instance)
54
54
  end.to change { created_transactions.length }.by(1)
55
55
 
56
56
  expect(last_transaction).to be_completed
@@ -96,7 +96,7 @@ if DependencyHelper.que_present?
96
96
 
97
97
  expect do
98
98
  expect do
99
- perform_job(instance)
99
+ perform_que_job(instance)
100
100
  end.to raise_error(ExampleException)
101
101
  end.to change { created_transactions.length }.by(1)
102
102
 
@@ -131,7 +131,7 @@ if DependencyHelper.que_present?
131
131
  it "reports errors and not re-raise them" do
132
132
  allow(instance).to receive(:run).and_raise(error)
133
133
 
134
- expect { perform_job(instance) }.to change { created_transactions.length }.by(1)
134
+ expect { perform_que_job(instance) }.to change { created_transactions.length }.by(1)
135
135
 
136
136
  expect(last_transaction).to be_completed
137
137
  transaction_hash = last_transaction.to_h
@@ -168,7 +168,7 @@ if DependencyHelper.que_present?
168
168
  end
169
169
 
170
170
  it "uses the custom action" do
171
- perform_job(instance)
171
+ perform_que_job(instance)
172
172
 
173
173
  expect(last_transaction).to be_completed
174
174
  transaction_hash = last_transaction.to_h
@@ -95,7 +95,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
95
95
 
96
96
  describe "internal Sidekiq job values" do
97
97
  it "does not save internal Sidekiq values as metadata on transaction" do
98
- perform_job
98
+ perform_sidekiq_job
99
99
 
100
100
  transaction_hash = transaction.to_h
101
101
  expect(transaction_hash["metadata"].keys)
@@ -110,7 +110,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
110
110
  end
111
111
 
112
112
  it "filters selected arguments" do
113
- perform_job
113
+ perform_sidekiq_job
114
114
 
115
115
  transaction_hash = transaction.to_h
116
116
  expect(transaction_hash["sample_data"]).to include(
@@ -133,7 +133,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
133
133
  end
134
134
 
135
135
  it "replaces the last argument (the secret bag) with an [encrypted data] string" do
136
- perform_job
136
+ perform_sidekiq_job
137
137
 
138
138
  transaction_hash = transaction.to_h
139
139
  expect(transaction_hash["sample_data"]).to include(
@@ -159,7 +159,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
159
159
  end
160
160
 
161
161
  it "uses the delayed class and method name for the action" do
162
- perform_job
162
+ perform_sidekiq_job
163
163
 
164
164
  transaction_hash = transaction.to_h
165
165
  expect(transaction_hash["action"]).to eq("DelayedTestClass.foo_method")
@@ -172,7 +172,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
172
172
  before { item["args"] = [] }
173
173
 
174
174
  it "logs a warning and uses the default argument" do
175
- perform_job
175
+ perform_sidekiq_job
176
176
 
177
177
  transaction_hash = transaction.to_h
178
178
  expect(transaction_hash["action"]).to eq("Sidekiq::Extensions::DelayedClass#perform")
@@ -199,7 +199,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
199
199
  end
200
200
 
201
201
  it "uses the delayed class and method name for the action" do
202
- perform_job
202
+ perform_sidekiq_job
203
203
 
204
204
  transaction_hash = transaction.to_h
205
205
  expect(transaction_hash["action"]).to eq("DelayedTestClass#foo_method")
@@ -212,7 +212,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
212
212
  before { item["args"] = [] }
213
213
 
214
214
  it "logs a warning and uses the default argument" do
215
- perform_job
215
+ perform_sidekiq_job
216
216
 
217
217
  transaction_hash = transaction.to_h
218
218
  expect(transaction_hash["action"]).to eq("Sidekiq::Extensions::DelayedModel#perform")
@@ -233,7 +233,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
233
233
  expect(Appsignal).to receive(:increment_counter)
234
234
  .with("sidekiq_queue_job_count", 1, { :queue => "default", :status => :processed })
235
235
  expect do
236
- perform_job { raise error, "uh oh" }
236
+ perform_sidekiq_job { raise error, "uh oh" }
237
237
  end.to raise_error(error)
238
238
 
239
239
  transaction_hash = transaction.to_h
@@ -271,7 +271,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
271
271
  it "reports the worker name as the action, copies the namespace and tags" do
272
272
  Appsignal.config = project_fixture_config("production")
273
273
  with_rails_error_reporter do
274
- perform_job do
274
+ perform_sidekiq_job do
275
275
  Appsignal.tag_job("test_tag" => "value")
276
276
  Rails.error.handle do
277
277
  raise ExampleStandardError, "uh oh"
@@ -301,7 +301,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
301
301
  # https://github.com/rspec/rspec-mocks/issues/1460
302
302
  expect(Appsignal).to receive(:increment_counter)
303
303
  .with("sidekiq_queue_job_count", 1, { :queue => "default", :status => :processed })
304
- perform_job
304
+ perform_sidekiq_job
305
305
 
306
306
  transaction_hash = transaction.to_h
307
307
  expect(transaction_hash).to include(
@@ -330,7 +330,7 @@ describe Appsignal::Integrations::SidekiqMiddleware, :with_yaml_parse_error => f
330
330
  end
331
331
  end
332
332
 
333
- def perform_job
333
+ def perform_sidekiq_job
334
334
  Timecop.freeze(Time.parse("2001-01-01 10:01:00UTC")) do
335
335
  exception = nil
336
336
  plugin.call(worker, item, queue) do
@@ -407,7 +407,7 @@ if DependencyHelper.active_job_present?
407
407
  end
408
408
  end
409
409
  let(:expected_tags) do
410
- {}.tap do |hash|
410
+ { "executions" => 1 }.tap do |hash|
411
411
  hash["active_job_id"] = kind_of(String)
412
412
  if DependencyHelper.rails_version >= Gem::Version.new("5.0.0")
413
413
  hash["provider_job_id"] = kind_of(String)
@@ -460,7 +460,7 @@ if DependencyHelper.active_job_present?
460
460
  end
461
461
 
462
462
  it "reports the transaction from the ActiveJob integration" do
463
- perform_job(ActiveJobSidekiqTestJob, given_args)
463
+ perform_sidekiq_job(ActiveJobSidekiqTestJob, given_args)
464
464
 
465
465
  transaction = last_transaction
466
466
  transaction_hash = transaction.to_h
@@ -488,7 +488,7 @@ if DependencyHelper.active_job_present?
488
488
  context "with error" do
489
489
  it "reports the error on the transaction from the ActiveRecord integration" do
490
490
  expect do
491
- perform_job(ActiveJobSidekiqErrorTestJob, given_args)
491
+ perform_sidekiq_job(ActiveJobSidekiqErrorTestJob, given_args)
492
492
  end.to raise_error(RuntimeError, "uh oh")
493
493
 
494
494
  transaction = last_transaction
@@ -557,7 +557,7 @@ if DependencyHelper.active_job_present?
557
557
  end
558
558
  end
559
559
 
560
- def perform_job(job_class, args)
560
+ def perform_sidekiq_job(job_class, args)
561
561
  perform_sidekiq { job_class.perform_later(args) }
562
562
  end
563
563
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.2
4
+ version: 3.7.3
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Beekman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-05-06 00:00:00.000000000 Z
13
+ date: 2024-05-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -466,7 +466,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
466
466
  - !ruby/object:Gem::Version
467
467
  version: '0'
468
468
  requirements: []
469
- rubygems_version: 3.5.9
469
+ rubygems_version: 3.5.10
470
470
  signing_key:
471
471
  specification_version: 4
472
472
  summary: Logs performance and exception data from your app to appsignal.com