appsignal 3.9.2-java → 3.9.3-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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +3135 -0
  3. data/.rubocop.yml +28 -20
  4. data/.rubocop_todo.yml +7 -33
  5. data/CHANGELOG.md +38 -0
  6. data/Rakefile +79 -64
  7. data/appsignal.gemspec +1 -1
  8. data/build_matrix.yml +109 -179
  9. data/ext/base.rb +1 -1
  10. data/gemfiles/hanami-2.1.gemfile +7 -0
  11. data/lib/appsignal/cli/diagnose.rb +1 -1
  12. data/lib/appsignal/config.rb +1 -1
  13. data/lib/appsignal/demo.rb +0 -1
  14. data/lib/appsignal/environment.rb +5 -1
  15. data/lib/appsignal/extension/jruby.rb +1 -1
  16. data/lib/appsignal/helpers/instrumentation.rb +1 -1
  17. data/lib/appsignal/integrations/grape.rb +19 -47
  18. data/lib/appsignal/integrations/hanami.rb +8 -7
  19. data/lib/appsignal/integrations/padrino.rb +46 -43
  20. data/lib/appsignal/integrations/railtie.rb +0 -3
  21. data/lib/appsignal/integrations/sinatra.rb +0 -1
  22. data/lib/appsignal/probes/gvl.rb +24 -2
  23. data/lib/appsignal/probes/sidekiq.rb +1 -1
  24. data/lib/appsignal/probes.rb +1 -1
  25. data/lib/appsignal/rack/abstract_middleware.rb +62 -28
  26. data/lib/appsignal/rack/event_handler.rb +12 -3
  27. data/lib/appsignal/rack/grape_middleware.rb +40 -0
  28. data/lib/appsignal/rack/hanami_middleware.rb +1 -11
  29. data/lib/appsignal/rack/rails_instrumentation.rb +14 -55
  30. data/lib/appsignal/utils/integration_memory_logger.rb +78 -0
  31. data/lib/appsignal/utils.rb +1 -0
  32. data/lib/appsignal/version.rb +1 -1
  33. data/lib/appsignal.rb +34 -33
  34. data/spec/.rubocop.yml +1 -1
  35. data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
  36. data/spec/lib/appsignal/cli/install_spec.rb +3 -3
  37. data/spec/lib/appsignal/config_spec.rb +7 -5
  38. data/spec/lib/appsignal/demo_spec.rb +38 -41
  39. data/spec/lib/appsignal/hooks/action_cable_spec.rb +86 -167
  40. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +8 -20
  41. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +38 -84
  42. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +16 -37
  43. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +4 -4
  44. data/spec/lib/appsignal/hooks/activejob_spec.rb +111 -200
  45. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +54 -91
  46. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +14 -32
  47. data/spec/lib/appsignal/hooks/excon_spec.rb +8 -12
  48. data/spec/lib/appsignal/hooks/net_http_spec.rb +7 -42
  49. data/spec/lib/appsignal/hooks/rake_spec.rb +9 -19
  50. data/spec/lib/appsignal/hooks/redis_client_spec.rb +18 -30
  51. data/spec/lib/appsignal/hooks/redis_spec.rb +10 -16
  52. data/spec/lib/appsignal/hooks/resque_spec.rb +42 -62
  53. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +33 -74
  54. data/spec/lib/appsignal/integrations/hanami_spec.rb +79 -21
  55. data/spec/lib/appsignal/integrations/http_spec.rb +12 -20
  56. data/spec/lib/appsignal/integrations/net_http_spec.rb +33 -0
  57. data/spec/lib/appsignal/integrations/object_spec.rb +29 -36
  58. data/spec/lib/appsignal/integrations/padrino_spec.rb +47 -70
  59. data/spec/lib/appsignal/integrations/que_spec.rb +43 -70
  60. data/spec/lib/appsignal/integrations/railtie_spec.rb +26 -67
  61. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +86 -160
  62. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -1
  63. data/spec/lib/appsignal/integrations/webmachine_spec.rb +28 -39
  64. data/spec/lib/appsignal/probes/gvl_spec.rb +80 -3
  65. data/spec/lib/appsignal/probes_spec.rb +7 -4
  66. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +215 -106
  67. data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -78
  68. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +2 -12
  69. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +234 -0
  70. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +2 -16
  71. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +67 -131
  72. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +36 -44
  73. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +68 -86
  74. data/spec/lib/appsignal/transaction_spec.rb +76 -90
  75. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +163 -0
  76. data/spec/lib/appsignal_spec.rb +363 -342
  77. data/spec/support/helpers/dependency_helper.rb +6 -1
  78. data/spec/support/helpers/std_streams_helper.rb +1 -1
  79. data/spec/support/helpers/transaction_helpers.rb +8 -0
  80. data/spec/support/matchers/transaction.rb +185 -0
  81. data/spec/support/mocks/dummy_app.rb +20 -0
  82. data/spec/support/shared_examples/instrument.rb +17 -12
  83. data/spec/support/testing.rb +18 -9
  84. metadata +15 -10
  85. data/.semaphore/semaphore.yml +0 -2347
  86. data/script/lint_git +0 -22
  87. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -239
  88. data/spec/support/matchers/be_completed.rb +0 -5
  89. /data/gemfiles/{hanami.gemfile → hanami-2.0.gemfile} +0 -0
@@ -5,22 +5,13 @@ shared_examples "activesupport instrument override" do
5
5
  end
6
6
 
7
7
  expect(return_value).to eq "value"
8
- expect(transaction.to_h["events"]).to match([
9
- {
10
- "allocation_count" => kind_of(Integer),
11
- "body" => "SQL",
12
- "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
13
- "child_allocation_count" => kind_of(Integer),
14
- "child_duration" => kind_of(Float),
15
- "child_gc_duration" => kind_of(Float),
16
- "count" => 1,
17
- "duration" => kind_of(Float),
18
- "gc_duration" => kind_of(Float),
19
- "name" => "sql.active_record",
20
- "start" => kind_of(Float),
21
- "title" => ""
22
- }
23
- ])
8
+ expect(transaction).to include_event(
9
+ "body" => "SQL",
10
+ "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
11
+ "count" => 1,
12
+ "name" => "sql.active_record",
13
+ "title" => ""
14
+ )
24
15
  end
25
16
 
26
17
  it "instruments an ActiveSupport::Notifications.instrument event with no registered formatter" do
@@ -29,53 +20,34 @@ shared_examples "activesupport instrument override" do
29
20
  end
30
21
 
31
22
  expect(return_value).to eq "value"
32
- expect(transaction.to_h["events"]).to match([
33
- {
34
- "allocation_count" => kind_of(Integer),
35
- "body" => "",
36
- "body_format" => Appsignal::EventFormatter::DEFAULT,
37
- "child_allocation_count" => kind_of(Integer),
38
- "child_duration" => kind_of(Float),
39
- "child_gc_duration" => kind_of(Float),
40
- "count" => 1,
41
- "duration" => kind_of(Float),
42
- "gc_duration" => kind_of(Float),
43
- "name" => "no-registered.formatter",
44
- "start" => kind_of(Float),
45
- "title" => ""
46
- }
47
- ])
23
+ expect(transaction).to include_event(
24
+ "body" => "",
25
+ "body_format" => Appsignal::EventFormatter::DEFAULT,
26
+ "count" => 1,
27
+ "name" => "no-registered.formatter",
28
+ "title" => ""
29
+ )
48
30
  end
49
31
 
50
32
  it "converts non-string names to strings" do
51
33
  as.instrument(:not_a_string) {} # rubocop:disable Lint/EmptyBlock
52
- expect(transaction.to_h["events"]).to match([
53
- {
54
- "allocation_count" => kind_of(Integer),
55
- "body" => "",
56
- "body_format" => Appsignal::EventFormatter::DEFAULT,
57
- "child_allocation_count" => kind_of(Integer),
58
- "child_duration" => kind_of(Float),
59
- "child_gc_duration" => kind_of(Float),
60
- "count" => 1,
61
- "duration" => kind_of(Float),
62
- "gc_duration" => kind_of(Float),
63
- "name" => "not_a_string",
64
- "start" => kind_of(Float),
65
- "title" => ""
66
- }
67
- ])
34
+ expect(transaction).to include_event(
35
+ "body" => "",
36
+ "body_format" => Appsignal::EventFormatter::DEFAULT,
37
+ "count" => 1,
38
+ "name" => "not_a_string",
39
+ "title" => ""
40
+ )
68
41
  end
69
42
 
70
43
  it "does not instrument events whose name starts with a bang" do
71
- expect(Appsignal::Transaction.current).not_to receive(:start_event)
72
- expect(Appsignal::Transaction.current).not_to receive(:finish_event)
73
-
74
44
  return_value = as.instrument("!sql.active_record", :sql => "SQL") do
75
45
  "value"
76
46
  end
77
47
 
78
48
  expect(return_value).to eq "value"
49
+
50
+ expect(transaction).to_not include_events
79
51
  end
80
52
 
81
53
  context "when an error is raised in an instrumented block" do
@@ -86,22 +58,13 @@ shared_examples "activesupport instrument override" do
86
58
  end
87
59
  end.to raise_error(ExampleException, "foo")
88
60
 
89
- expect(transaction.to_h["events"]).to match([
90
- {
91
- "allocation_count" => kind_of(Integer),
92
- "body" => "SQL",
93
- "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
94
- "child_allocation_count" => kind_of(Integer),
95
- "child_duration" => kind_of(Float),
96
- "child_gc_duration" => kind_of(Float),
97
- "count" => 1,
98
- "duration" => kind_of(Float),
99
- "gc_duration" => kind_of(Float),
100
- "name" => "sql.active_record",
101
- "start" => kind_of(Float),
102
- "title" => ""
103
- }
104
- ])
61
+ expect(transaction).to include_event(
62
+ "body" => "SQL",
63
+ "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
64
+ "count" => 1,
65
+ "name" => "sql.active_record",
66
+ "title" => ""
67
+ )
105
68
  end
106
69
  end
107
70
 
@@ -113,22 +76,13 @@ shared_examples "activesupport instrument override" do
113
76
  end
114
77
  end.to throw_symbol(:foo)
115
78
 
116
- expect(transaction.to_h["events"]).to match([
117
- {
118
- "allocation_count" => kind_of(Integer),
119
- "body" => "SQL",
120
- "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
121
- "child_allocation_count" => kind_of(Integer),
122
- "child_duration" => kind_of(Float),
123
- "child_gc_duration" => kind_of(Float),
124
- "count" => 1,
125
- "duration" => kind_of(Float),
126
- "gc_duration" => kind_of(Float),
127
- "name" => "sql.active_record",
128
- "start" => kind_of(Float),
129
- "title" => ""
130
- }
131
- ])
79
+ expect(transaction).to include_event(
80
+ "body" => "SQL",
81
+ "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
82
+ "count" => 1,
83
+ "name" => "sql.active_record",
84
+ "title" => ""
85
+ )
132
86
  end
133
87
  end
134
88
 
@@ -139,7 +93,7 @@ shared_examples "activesupport instrument override" do
139
93
  Appsignal::Transaction.complete_current!
140
94
  end
141
95
 
142
- expect(transaction.to_h["events"]).to match([])
96
+ expect(transaction).to_not include_events
143
97
  end
144
98
  end
145
99
  end
@@ -5,54 +5,33 @@ shared_examples "activesupport start finish override" do
5
5
  instrumenter.start("sql.active_record", :sql => "SQL")
6
6
  instrumenter.finish("sql.active_record", {})
7
7
 
8
- expect(transaction.to_h["events"]).to match([
9
- {
10
- "allocation_count" => kind_of(Integer),
11
- "body" => "",
12
- "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
13
- "child_allocation_count" => kind_of(Integer),
14
- "child_duration" => kind_of(Float),
15
- "child_gc_duration" => kind_of(Float),
16
- "count" => 1,
17
- "duration" => kind_of(Float),
18
- "gc_duration" => kind_of(Float),
19
- "name" => "sql.active_record",
20
- "start" => kind_of(Float),
21
- "title" => ""
22
- }
23
- ])
8
+ expect(transaction).to include_event(
9
+ "body" => "",
10
+ "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
11
+ "count" => 1,
12
+ "name" => "sql.active_record",
13
+ "title" => ""
14
+ )
24
15
  end
25
16
 
26
17
  it "instruments an ActiveSupport::Notifications.start/finish event with payload on finish" do
27
18
  instrumenter.start("sql.active_record", {})
28
19
  instrumenter.finish("sql.active_record", :sql => "SQL")
29
20
 
30
- expect(transaction.to_h["events"]).to match([
31
- {
32
- "allocation_count" => kind_of(Integer),
33
- "body" => "SQL",
34
- "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
35
- "child_allocation_count" => kind_of(Integer),
36
- "child_duration" => kind_of(Float),
37
- "child_gc_duration" => kind_of(Float),
38
- "count" => 1,
39
- "duration" => kind_of(Float),
40
- "gc_duration" => kind_of(Float),
41
- "name" => "sql.active_record",
42
- "start" => kind_of(Float),
43
- "title" => ""
44
- }
45
- ])
21
+ expect(transaction).to include_event(
22
+ "body" => "SQL",
23
+ "body_format" => Appsignal::EventFormatter::SQL_BODY_FORMAT,
24
+ "count" => 1,
25
+ "name" => "sql.active_record",
26
+ "title" => ""
27
+ )
46
28
  end
47
29
 
48
30
  it "does not instrument events whose name starts with a bang" do
49
- expect(Appsignal::Transaction.current).not_to receive(:start_event)
50
- expect(Appsignal::Transaction.current).not_to receive(:finish_event)
51
-
52
31
  instrumenter.start("!sql.active_record", {})
53
32
  instrumenter.finish("!sql.active_record", {})
54
33
 
55
- expect(transaction.to_h["events"]).to be_empty
34
+ expect(transaction).to_not include_events
56
35
  end
57
36
 
58
37
  context "when a transaction is completed in an instrumented block" do
@@ -63,7 +42,7 @@ shared_examples "activesupport start finish override" do
63
42
  Appsignal::Transaction.complete_current!
64
43
  instrumenter.finish("sql.active_record", {})
65
44
 
66
- expect(transaction.to_h["events"]).to match([])
45
+ expect(transaction).to_not include_events
67
46
  end
68
47
  end
69
48
  end
@@ -1,4 +1,4 @@
1
- require_relative "./active_support_notifications/instrument_shared_examples"
1
+ require_relative "active_support_notifications/instrument_shared_examples"
2
2
 
3
3
  describe Appsignal::Hooks::ActiveSupportNotificationsHook do
4
4
  if active_support_present?
@@ -23,19 +23,19 @@ describe Appsignal::Hooks::ActiveSupportNotificationsHook do
23
23
  it_behaves_like "activesupport instrument override"
24
24
 
25
25
  if defined?(::ActiveSupport::Notifications::Fanout::Handle)
26
- require_relative "./active_support_notifications/start_finish_shared_examples"
26
+ require_relative "active_support_notifications/start_finish_shared_examples"
27
27
 
28
28
  it_behaves_like "activesupport start finish override"
29
29
  end
30
30
 
31
31
  if ::ActiveSupport::Notifications::Instrumenter.method_defined?(:start)
32
- require_relative "./active_support_notifications/start_finish_shared_examples"
32
+ require_relative "active_support_notifications/start_finish_shared_examples"
33
33
 
34
34
  it_behaves_like "activesupport start finish override"
35
35
  end
36
36
 
37
37
  if ::ActiveSupport::Notifications::Instrumenter.method_defined?(:finish_with_state)
38
- require_relative "./active_support_notifications/finish_with_state_shared_examples"
38
+ require_relative "active_support_notifications/finish_with_state_shared_examples"
39
39
 
40
40
  it_behaves_like "activesupport finish_with_state override"
41
41
  end