appsignal 3.10.0-java → 3.11.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +88 -0
  4. data/Gemfile +1 -0
  5. data/benchmark.rake +99 -42
  6. data/lib/appsignal/cli/demo.rb +0 -1
  7. data/lib/appsignal/config.rb +54 -98
  8. data/lib/appsignal/demo.rb +15 -20
  9. data/lib/appsignal/event_formatter/rom/sql_formatter.rb +1 -0
  10. data/lib/appsignal/event_formatter.rb +3 -2
  11. data/lib/appsignal/helpers/instrumentation.rb +331 -19
  12. data/lib/appsignal/hooks/action_cable.rb +21 -16
  13. data/lib/appsignal/hooks/active_job.rb +14 -8
  14. data/lib/appsignal/hooks/delayed_job.rb +1 -1
  15. data/lib/appsignal/hooks/shoryuken.rb +3 -63
  16. data/lib/appsignal/integrations/action_cable.rb +5 -7
  17. data/lib/appsignal/integrations/active_support_notifications.rb +1 -0
  18. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +36 -35
  19. data/lib/appsignal/integrations/data_mapper.rb +1 -0
  20. data/lib/appsignal/integrations/delayed_job_plugin.rb +27 -33
  21. data/lib/appsignal/integrations/dry_monitor.rb +1 -0
  22. data/lib/appsignal/integrations/excon.rb +1 -0
  23. data/lib/appsignal/integrations/http.rb +1 -0
  24. data/lib/appsignal/integrations/net_http.rb +1 -0
  25. data/lib/appsignal/integrations/object.rb +6 -0
  26. data/lib/appsignal/integrations/que.rb +13 -20
  27. data/lib/appsignal/integrations/railtie.rb +1 -1
  28. data/lib/appsignal/integrations/rake.rb +1 -5
  29. data/lib/appsignal/integrations/redis.rb +1 -0
  30. data/lib/appsignal/integrations/redis_client.rb +1 -0
  31. data/lib/appsignal/integrations/resque.rb +2 -5
  32. data/lib/appsignal/integrations/shoryuken.rb +75 -0
  33. data/lib/appsignal/integrations/sidekiq.rb +7 -15
  34. data/lib/appsignal/integrations/unicorn.rb +1 -0
  35. data/lib/appsignal/integrations/webmachine.rb +2 -5
  36. data/lib/appsignal/logger.rb +7 -3
  37. data/lib/appsignal/probes/helpers.rb +1 -0
  38. data/lib/appsignal/probes/mri.rb +1 -0
  39. data/lib/appsignal/probes/sidekiq.rb +1 -0
  40. data/lib/appsignal/probes.rb +3 -0
  41. data/lib/appsignal/rack/abstract_middleware.rb +18 -12
  42. data/lib/appsignal/rack/event_handler.rb +39 -8
  43. data/lib/appsignal/rack/generic_instrumentation.rb +1 -0
  44. data/lib/appsignal/rack/grape_middleware.rb +2 -1
  45. data/lib/appsignal/rack/streaming_listener.rb +1 -0
  46. data/lib/appsignal/rack.rb +29 -0
  47. data/lib/appsignal/span.rb +1 -0
  48. data/lib/appsignal/transaction.rb +308 -101
  49. data/lib/appsignal/utils/data.rb +0 -1
  50. data/lib/appsignal/utils/hash_sanitizer.rb +0 -1
  51. data/lib/appsignal/utils/integration_logger.rb +0 -13
  52. data/lib/appsignal/utils/integration_memory_logger.rb +0 -13
  53. data/lib/appsignal/utils/json.rb +0 -1
  54. data/lib/appsignal/utils/query_params_sanitizer.rb +0 -1
  55. data/lib/appsignal/utils/stdout_and_logger_message.rb +0 -1
  56. data/lib/appsignal/utils.rb +6 -0
  57. data/lib/appsignal/version.rb +1 -1
  58. data/lib/appsignal.rb +6 -5
  59. data/spec/lib/appsignal/capistrano2_spec.rb +1 -1
  60. data/spec/lib/appsignal/config_spec.rb +138 -43
  61. data/spec/lib/appsignal/hooks/action_cable_spec.rb +43 -74
  62. data/spec/lib/appsignal/hooks/activejob_spec.rb +9 -0
  63. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +2 -443
  64. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +0 -171
  65. data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +459 -0
  66. data/spec/lib/appsignal/integrations/que_spec.rb +3 -4
  67. data/spec/lib/appsignal/integrations/shoryuken_spec.rb +167 -0
  68. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +4 -4
  69. data/spec/lib/appsignal/integrations/webmachine_spec.rb +13 -1
  70. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +48 -3
  71. data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -10
  72. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +4 -2
  73. data/spec/lib/appsignal/rack_spec.rb +63 -0
  74. data/spec/lib/appsignal/transaction_spec.rb +1634 -1071
  75. data/spec/lib/appsignal/utils/integration_logger_spec.rb +12 -16
  76. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +0 -10
  77. data/spec/lib/appsignal_spec.rb +323 -10
  78. data/spec/support/helpers/transaction_helpers.rb +44 -20
  79. data/spec/support/matchers/transaction.rb +15 -1
  80. data/spec/support/testing.rb +1 -1
  81. metadata +6 -2
@@ -1,25 +1,21 @@
1
1
  describe Appsignal::Utils::IntegrationLogger do
2
- let(:log) { std_stream }
2
+ let(:log_stream) { std_stream }
3
+ let(:logs) { log_contents(log_stream) }
3
4
  let(:logger) do
4
- Appsignal::Utils::IntegrationLogger.new(log).tap do |l|
5
+ Appsignal::Utils::IntegrationLogger.new(log_stream).tap do |l|
5
6
  l.formatter = logger_formatter
6
7
  end
7
8
  end
8
9
 
9
- describe "#seen_keys" do
10
- it "returns a Set" do
11
- expect(logger.seen_keys).to be_a(Set)
12
- end
13
- end
10
+ it "logs messages" do
11
+ logger.debug("debug message")
12
+ logger.info("info message")
13
+ logger.warn("warning message")
14
+ logger.error("error message")
14
15
 
15
- describe "#warn_once_then_debug" do
16
- it "only warns once, then uses debug" do
17
- message = "This is a log line"
18
- 3.times { logger.warn_once_then_debug(:key, message) }
19
-
20
- logs = log_contents(log)
21
- expect(logs.scan(/#{Regexp.escape(log_line(:WARN, message))}/).count).to eql(1)
22
- expect(logs.scan(/#{Regexp.escape(log_line(:DEBUG, message))}/).count).to eql(2)
23
- end
16
+ expect(logs).to contains_log(:debug, "debug message")
17
+ expect(logs).to contains_log(:info, "info message")
18
+ expect(logs).to contains_log(:warn, "warning message")
19
+ expect(logs).to contains_log(:error, "error message")
24
20
  end
25
21
  end
@@ -68,16 +68,6 @@ describe Appsignal::Utils::IntegrationLogger do
68
68
  end
69
69
  end
70
70
 
71
- describe "#warn_once_then_debug" do
72
- it "only warns once, then uses debug" do
73
- message = "This is a log line"
74
- 3.times { logger.warn_once_then_debug(:key, message) }
75
-
76
- expect(logger.messages[:WARN]).to eq([message])
77
- expect(logger.messages[:DEBUG]).to eq([message, message])
78
- end
79
- end
80
-
81
71
  describe "#error" do
82
72
  it "adds a log message with the error severity" do
83
73
  logger.error("error message")
@@ -358,7 +358,178 @@ describe Appsignal do
358
358
  before { start_agent }
359
359
  around { |example| keep_transactions { example.run } }
360
360
 
361
+ describe ".monitor" do
362
+ it "creates a transaction" do
363
+ expect do
364
+ Appsignal.monitor(:action => "MyAction")
365
+ end.to(change { created_transactions.count }.by(1))
366
+
367
+ transaction = last_transaction
368
+ expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
369
+ expect(transaction).to have_action("MyAction")
370
+ expect(transaction).to_not have_error
371
+ expect(transaction).to_not include_events
372
+ expect(transaction).to_not have_queue_start
373
+ expect(transaction).to be_completed
374
+ end
375
+
376
+ it "returns the block's return value" do
377
+ expect(Appsignal.monitor(:action => nil) { :return_value }).to eq(:return_value)
378
+ end
379
+
380
+ it "sets a custom namespace via the namespace argument" do
381
+ Appsignal.monitor(:namespace => "custom", :action => nil)
382
+
383
+ expect(last_transaction).to have_namespace("custom")
384
+ end
385
+
386
+ it "doesn't overwrite custom namespace set in the block" do
387
+ Appsignal.monitor(:namespace => "custom", :action => nil) do
388
+ Appsignal.set_namespace("more custom")
389
+ end
390
+
391
+ expect(last_transaction).to have_namespace("more custom")
392
+ end
393
+
394
+ it "sets the action via the action argument using a string" do
395
+ Appsignal.monitor(:action => "custom")
396
+
397
+ expect(last_transaction).to have_action("custom")
398
+ end
399
+
400
+ it "sets the action via the action argument using a symbol" do
401
+ Appsignal.monitor(:action => :custom)
402
+
403
+ expect(last_transaction).to have_action("custom")
404
+ end
405
+
406
+ it "doesn't overwrite custom action set in the block" do
407
+ Appsignal.monitor(:action => "custom") do
408
+ Appsignal.set_action("more custom")
409
+ end
410
+
411
+ expect(last_transaction).to have_action("more custom")
412
+ end
413
+
414
+ it "doesn't set the action when value is nil" do
415
+ Appsignal.monitor(:action => nil)
416
+
417
+ expect(last_transaction).to_not have_action
418
+ end
419
+
420
+ it "doesn't set the action when value is :set_later" do
421
+ Appsignal.monitor(:action => :set_later)
422
+
423
+ expect(last_transaction).to_not have_action
424
+ end
425
+
426
+ it "reports exceptions that occur in the block" do
427
+ expect do
428
+ Appsignal.monitor :action => nil do
429
+ raise ExampleException, "error message"
430
+ end
431
+ end.to raise_error(ExampleException, "error message")
432
+
433
+ expect(last_transaction).to have_error("ExampleException", "error message")
434
+ end
435
+
436
+ context "with already active transction" do
437
+ let(:err_stream) { std_stream }
438
+ let(:stderr) { err_stream.read }
439
+ let(:transaction) { http_request_transaction }
440
+ before do
441
+ set_current_transaction(transaction)
442
+ transaction.set_action("My action")
443
+ end
444
+
445
+ it "doesn't create a new transaction" do
446
+ logs = nil
447
+ expect do
448
+ logs =
449
+ capture_logs do
450
+ capture_std_streams(std_stream, err_stream) do
451
+ Appsignal.monitor(:action => nil)
452
+ end
453
+ end
454
+ end.to_not(change { created_transactions.count })
455
+
456
+ warning = "An active transaction around this 'Appsignal.monitor' call."
457
+ expect(logs).to contains_log(:warn, warning)
458
+ expect(stderr).to include("appsignal WARNING: #{warning}")
459
+ end
460
+
461
+ it "does not overwrite the parent transaction's namespace" do
462
+ silence { Appsignal.monitor(:namespace => "custom", :action => nil) }
463
+
464
+ expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
465
+ end
466
+
467
+ it "does not overwrite the parent transaction's action" do
468
+ silence { Appsignal.monitor(:action => "custom") }
469
+
470
+ expect(transaction).to have_action("My action")
471
+ end
472
+
473
+ it "doesn't complete the parent transaction" do
474
+ silence { Appsignal.monitor(:action => nil) }
475
+
476
+ expect(transaction).to_not be_completed
477
+ end
478
+ end
479
+ end
480
+
481
+ describe ".monitor_and_stop" do
482
+ it "calls Appsignal.stop after the block" do
483
+ allow(Appsignal).to receive(:stop)
484
+ Appsignal.monitor_and_stop(:namespace => "custom", :action => "My Action")
485
+
486
+ transaction = last_transaction
487
+ expect(transaction).to have_namespace("custom")
488
+ expect(transaction).to have_action("My Action")
489
+ expect(transaction).to be_completed
490
+
491
+ expect(Appsignal).to have_received(:stop).with("monitor_and_stop")
492
+ end
493
+ end
494
+
361
495
  describe ".monitor_transaction" do
496
+ it "prints a deprecation warning" do
497
+ err_stream = std_stream
498
+ capture_std_streams(std_stream, err_stream) do
499
+ Appsignal.monitor_transaction(
500
+ "perform_job.something",
501
+ :class => "BackgroundJob",
502
+ :method => "perform"
503
+ ) do
504
+ :return_value
505
+ end
506
+ end
507
+
508
+ expect(err_stream.read).to include(
509
+ "appsignal WARNING: The `Appsignal.monitor_transaction` helper is deprecated."
510
+ )
511
+ end
512
+
513
+ it "logs a deprecation warning" do
514
+ logs =
515
+ capture_logs do
516
+ silence do
517
+ Appsignal.monitor_transaction(
518
+ "perform_job.something",
519
+ :class => "BackgroundJob",
520
+ :method => "perform"
521
+ ) do
522
+ :return_value
523
+ end
524
+ end
525
+ end
526
+
527
+ expect(logs).to contains_log(
528
+ :warn,
529
+ "The `Appsignal.monitor_transaction` helper is deprecated."
530
+ )
531
+ end
532
+
362
533
  context "with a successful call" do
363
534
  it "instruments and completes for a background job" do
364
535
  return_value = nil
@@ -368,7 +539,8 @@ describe Appsignal do
368
539
  "perform_job.something",
369
540
  {
370
541
  :class => "BackgroundJob",
371
- :method => "perform"
542
+ :method => "perform",
543
+ :queue_start => fixed_time.to_i
372
544
  }
373
545
  ) do
374
546
  :return_value
@@ -380,6 +552,7 @@ describe Appsignal do
380
552
  expect(transaction).to have_namespace(Appsignal::Transaction::BACKGROUND_JOB)
381
553
  expect(transaction).to have_action("BackgroundJob#perform")
382
554
  expect(transaction).to include_event("name" => "perform_job.something")
555
+ expect(transaction).to have_queue_start(1_389_783_600_000)
383
556
  expect(transaction).to be_completed
384
557
  end
385
558
 
@@ -391,7 +564,8 @@ describe Appsignal do
391
564
  "process_action.something",
392
565
  {
393
566
  :controller => "BlogPostsController",
394
- :action => "show"
567
+ :action => "show",
568
+ "HTTP_X_REQUEST_START" => "t=#{fixed_time.to_i * 1000}"
395
569
  }
396
570
  ) do
397
571
  :return_value
@@ -403,6 +577,7 @@ describe Appsignal do
403
577
  expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
404
578
  expect(transaction).to have_action("BlogPostsController#show")
405
579
  expect(transaction).to include_event("name" => "process_action.something")
580
+ expect(transaction).to have_queue_start(1_389_783_600_000)
406
581
  expect(transaction).to be_completed
407
582
  end
408
583
  end
@@ -444,6 +619,43 @@ describe Appsignal do
444
619
  end
445
620
 
446
621
  describe ".monitor_single_transaction" do
622
+ it "prints a deprecation warning" do
623
+ err_stream = std_stream
624
+ capture_std_streams(std_stream, err_stream) do
625
+ Appsignal.monitor_single_transaction(
626
+ "perform_job.something",
627
+ :class => "BackgroundJob",
628
+ :method => "perform"
629
+ ) do
630
+ :return_value
631
+ end
632
+ end
633
+
634
+ expect(err_stream.read).to include(
635
+ "appsignal WARNING: The `Appsignal.monitor_single_transaction` helper is deprecated."
636
+ )
637
+ end
638
+
639
+ it "logs a deprecation warning" do
640
+ logs =
641
+ capture_logs do
642
+ silence do
643
+ Appsignal.monitor_single_transaction(
644
+ "perform_job.something",
645
+ :class => "BackgroundJob",
646
+ :method => "perform"
647
+ ) do
648
+ :return_value
649
+ end
650
+ end
651
+ end
652
+
653
+ expect(logs).to contains_log(
654
+ :warn,
655
+ "The `Appsignal.monitor_single_transaction` helper is deprecated."
656
+ )
657
+ end
658
+
447
659
  context "with a successful call" do
448
660
  it "calls monitor_transaction and Appsignal.stop" do
449
661
  expect(Appsignal).to receive(:stop)
@@ -521,9 +733,7 @@ describe Appsignal do
521
733
  end
522
734
 
523
735
  describe ".set_params" do
524
- before do
525
- start_agent
526
- end
736
+ before { start_agent }
527
737
 
528
738
  context "with transaction" do
529
739
  let(:transaction) { http_request_transaction }
@@ -561,6 +771,84 @@ describe Appsignal do
561
771
  end
562
772
  end
563
773
 
774
+ describe ".set_session_data" do
775
+ before { start_agent }
776
+
777
+ context "with transaction" do
778
+ let(:transaction) { http_request_transaction }
779
+ before { set_current_transaction(transaction) }
780
+
781
+ it "sets session data on the transaction" do
782
+ Appsignal.set_session_data("data" => "value1")
783
+
784
+ transaction._sample
785
+ expect(transaction).to include_session_data("data" => "value1")
786
+ end
787
+
788
+ it "overwrites the session data if called multiple times" do
789
+ Appsignal.set_session_data("data" => "value1")
790
+ Appsignal.set_session_data("data" => "value2")
791
+
792
+ transaction._sample
793
+ expect(transaction).to include_session_data("data" => "value2")
794
+ end
795
+
796
+ it "sets session data with a block on the transaction" do
797
+ Appsignal.set_session_data { { "data" => "value1" } }
798
+
799
+ transaction._sample
800
+ expect(transaction).to include_session_data("data" => "value1")
801
+ end
802
+ end
803
+
804
+ context "without transaction" do
805
+ it "does not set session data on the transaction" do
806
+ Appsignal.set_session_data("a" => "b")
807
+
808
+ expect_any_instance_of(Appsignal::Transaction).to_not receive(:set_session_data)
809
+ end
810
+ end
811
+ end
812
+
813
+ describe ".set_headers" do
814
+ before { start_agent }
815
+
816
+ context "with transaction" do
817
+ let(:transaction) { http_request_transaction }
818
+ before { set_current_transaction(transaction) }
819
+
820
+ it "sets request headers on the transaction" do
821
+ Appsignal.set_headers("PATH_INFO" => "/some-path")
822
+
823
+ transaction._sample
824
+ expect(transaction).to include_environment("PATH_INFO" => "/some-path")
825
+ end
826
+
827
+ it "overwrites the request headers if called multiple times" do
828
+ Appsignal.set_headers("PATH_INFO" => "/some-path1")
829
+ Appsignal.set_headers("PATH_INFO" => "/some-path2")
830
+
831
+ transaction._sample
832
+ expect(transaction).to include_environment("PATH_INFO" => "/some-path2")
833
+ end
834
+
835
+ it "sets request headers with a block on the transaction" do
836
+ Appsignal.set_headers { { "PATH_INFO" => "/some-path" } }
837
+
838
+ transaction._sample
839
+ expect(transaction).to include_environment("PATH_INFO" => "/some-path")
840
+ end
841
+ end
842
+
843
+ context "without transaction" do
844
+ it "does not set request headers on the transaction" do
845
+ Appsignal.set_headers("PATH_INFO" => "/some-path")
846
+
847
+ expect_any_instance_of(Appsignal::Transaction).to_not receive(:set_headers)
848
+ end
849
+ end
850
+ end
851
+
564
852
  describe ".set_custom_data" do
565
853
  before { start_agent }
566
854
 
@@ -1269,7 +1557,7 @@ describe Appsignal do
1269
1557
  end
1270
1558
  end
1271
1559
 
1272
- describe ".without_instrumentation" do
1560
+ describe ".ignore_instrumentation_events" do
1273
1561
  around { |example| keep_transactions { example.run } }
1274
1562
  let(:transaction) { http_request_transaction }
1275
1563
 
@@ -1281,20 +1569,44 @@ describe Appsignal do
1281
1569
  expect(transaction).to receive(:resume!).and_call_original
1282
1570
 
1283
1571
  Appsignal.instrument("register.this.event") { :do_nothing }
1284
- Appsignal.without_instrumentation do
1572
+ Appsignal.ignore_instrumentation_events do
1285
1573
  Appsignal.instrument("dont.register.this.event") { :do_nothing }
1286
1574
  end
1287
1575
 
1288
1576
  expect(transaction).to include_event("name" => "register.this.event")
1289
1577
  expect(transaction).to_not include_event("name" => "dont.register.this.event")
1290
1578
  end
1579
+
1580
+ it "has a without_instrumentation alias that prints a deprecation warning" do
1581
+ Appsignal.instrument("register.this.event") { :do_nothing }
1582
+ err_stream = std_stream
1583
+ logs =
1584
+ capture_logs do
1585
+ capture_std_streams(std_stream, err_stream) do
1586
+ Appsignal.without_instrumentation do
1587
+ Appsignal.instrument("dont.register.this.event") { :do_nothing }
1588
+ end
1589
+ end
1590
+ end
1591
+
1592
+ expect(transaction).to include_event("name" => "register.this.event")
1593
+ expect(transaction).to_not include_event("name" => "dont.register.this.event")
1594
+
1595
+ expect(logs).to contains_log(
1596
+ :warn,
1597
+ "The `Appsignal.without_instrumentation` helper is deprecated."
1598
+ )
1599
+ expect(err_stream.read).to include(
1600
+ "appsignal WARNING: The `Appsignal.without_instrumentation` helper is deprecated."
1601
+ )
1602
+ end
1291
1603
  end
1292
1604
 
1293
1605
  context "without current transaction" do
1294
1606
  let(:transaction) { nil }
1295
1607
 
1296
1608
  it "does not crash" do
1297
- Appsignal.without_instrumentation { :do_nothing }
1609
+ Appsignal.ignore_instrumentation_events { :do_nothing }
1298
1610
  end
1299
1611
  end
1300
1612
  end
@@ -1312,8 +1624,9 @@ describe Appsignal do
1312
1624
  Appsignal.start_logger
1313
1625
  end
1314
1626
  end
1315
- expect(stderr).to include("appsignal WARNING: Callng 'Appsignal.start_logger' is deprecated.")
1316
- expect(log).to contains_log(:warn, "Callng 'Appsignal.start_logger' is deprecated.")
1627
+ expect(stderr)
1628
+ .to include("appsignal WARNING: Calling 'Appsignal.start_logger' is deprecated.")
1629
+ expect(log).to contains_log(:warn, "Calling 'Appsignal.start_logger' is deprecated.")
1317
1630
  end
1318
1631
  end
1319
1632
 
@@ -7,26 +7,50 @@ module TransactionHelpers
7
7
  end
8
8
  end
9
9
 
10
- def background_job_transaction(args = {})
11
- Appsignal::Transaction.new(
12
- "1",
13
- Appsignal::Transaction::BACKGROUND_JOB,
14
- Appsignal::Transaction::GenericRequest.new({
15
- "SERVER_NAME" => "localhost",
16
- "action_dispatch.routes" => "not_available"
17
- }.merge(args))
18
- )
19
- end
20
-
21
- def http_request_transaction(args = {})
22
- Appsignal::Transaction.new(
23
- "1",
24
- Appsignal::Transaction::HTTP_REQUEST,
25
- Appsignal::Transaction::GenericRequest.new({
26
- "SERVER_NAME" => "localhost",
27
- "action_dispatch.routes" => "not_available"
28
- }.merge(args))
29
- )
10
+ def default_namespace
11
+ Appsignal::Transaction::HTTP_REQUEST
12
+ end
13
+
14
+ def create_transaction(namespace = default_namespace)
15
+ Appsignal::Transaction.create(namespace)
16
+ end
17
+
18
+ def new_transaction(namespace = default_namespace)
19
+ Appsignal::Transaction.new(SecureRandom.uuid, namespace)
20
+ end
21
+
22
+ def legacy_create_transaction(
23
+ id: "mock_transaction_id",
24
+ namespace: "mock_namespace",
25
+ request: legacy_request,
26
+ options: {}
27
+ )
28
+ Appsignal::Transaction.create(id, namespace, request, options)
29
+ end
30
+
31
+ def legacy_new_transaction(
32
+ id: "mock_transaction_id",
33
+ namespace: "mock_namespace",
34
+ request: legacy_request,
35
+ options: {}
36
+ )
37
+ Appsignal::Transaction.new(id, namespace, request, options)
38
+ end
39
+
40
+ def legacy_request(env = {})
41
+ Appsignal::Transaction::InternalGenericRequest.new(env)
42
+ end
43
+
44
+ def rack_request(env)
45
+ Rack::Request.new(env)
46
+ end
47
+
48
+ def background_job_transaction
49
+ new_transaction(Appsignal::Transaction::BACKGROUND_JOB)
50
+ end
51
+
52
+ def http_request_transaction
53
+ new_transaction(Appsignal::Transaction::HTTP_REQUEST)
30
54
  end
31
55
 
32
56
  # Returns the all {Appsignal::Transaction} objects created during this test
@@ -180,6 +180,20 @@ RSpec::Matchers.alias_matcher :include_breadcrumbs, :include_breadcrumb
180
180
 
181
181
  RSpec::Matchers.define :have_queue_start do |queue_start_time|
182
182
  match(:notify_expectation_failures => true) do |transaction|
183
- expect(transaction.ext.queue_start).to eq(queue_start_time)
183
+ actual_start = transaction.ext.queue_start
184
+ if queue_start_time
185
+ expect(actual_start).to eq(queue_start_time)
186
+ else
187
+ expect(actual_start).to_not be_nil
188
+ end
189
+ end
190
+
191
+ match_when_negated(:notify_expectation_failures => true) do |transaction|
192
+ actual_start = transaction.ext.queue_start
193
+ if queue_start_time
194
+ expect(actual_start).to_not eq(queue_start_time)
195
+ else
196
+ expect(actual_start).to be_nil
197
+ end
184
198
  end
185
199
  end
@@ -134,7 +134,7 @@ module AppsignalTest
134
134
 
135
135
  module InstanceMethods
136
136
  def _sample
137
- sample_data
137
+ _sample_data
138
138
  end
139
139
  end
140
140
  end
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.10.0
4
+ version: 3.11.0
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-07-08 00:00:00.000000000 Z
13
+ date: 2024-07-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack
@@ -275,6 +275,7 @@ files:
275
275
  - lib/appsignal/integrations/redis.rb
276
276
  - lib/appsignal/integrations/redis_client.rb
277
277
  - lib/appsignal/integrations/resque.rb
278
+ - lib/appsignal/integrations/shoryuken.rb
278
279
  - lib/appsignal/integrations/sidekiq.rb
279
280
  - lib/appsignal/integrations/sinatra.rb
280
281
  - lib/appsignal/integrations/unicorn.rb
@@ -376,6 +377,7 @@ files:
376
377
  - spec/lib/appsignal/hooks/webmachine_spec.rb
377
378
  - spec/lib/appsignal/hooks_spec.rb
378
379
  - spec/lib/appsignal/integrations/data_mapper_spec.rb
380
+ - spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb
379
381
  - spec/lib/appsignal/integrations/hanami_spec.rb
380
382
  - spec/lib/appsignal/integrations/http_spec.rb
381
383
  - spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
@@ -384,6 +386,7 @@ files:
384
386
  - spec/lib/appsignal/integrations/padrino_spec.rb
385
387
  - spec/lib/appsignal/integrations/que_spec.rb
386
388
  - spec/lib/appsignal/integrations/railtie_spec.rb
389
+ - spec/lib/appsignal/integrations/shoryuken_spec.rb
387
390
  - spec/lib/appsignal/integrations/sidekiq_spec.rb
388
391
  - spec/lib/appsignal/integrations/sinatra_spec.rb
389
392
  - spec/lib/appsignal/integrations/webmachine_spec.rb
@@ -403,6 +406,7 @@ files:
403
406
  - spec/lib/appsignal/rack/rails_instrumentation_spec.rb
404
407
  - spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb
405
408
  - spec/lib/appsignal/rack/streaming_listener_spec.rb
409
+ - spec/lib/appsignal/rack_spec.rb
406
410
  - spec/lib/appsignal/span_spec.rb
407
411
  - spec/lib/appsignal/system_spec.rb
408
412
  - spec/lib/appsignal/transaction_spec.rb