appsignal 3.9.2-java → 3.10.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 (105) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +3138 -0
  3. data/.rubocop.yml +28 -20
  4. data/.rubocop_todo.yml +7 -33
  5. data/CHANGELOG.md +130 -0
  6. data/README.md +0 -1
  7. data/Rakefile +80 -65
  8. data/appsignal.gemspec +1 -1
  9. data/build_matrix.yml +112 -184
  10. data/ext/base.rb +1 -1
  11. data/gemfiles/hanami-2.1.gemfile +7 -0
  12. data/gemfiles/webmachine1.gemfile +5 -4
  13. data/lib/appsignal/cli/diagnose.rb +1 -1
  14. data/lib/appsignal/config.rb +5 -1
  15. data/lib/appsignal/demo.rb +0 -1
  16. data/lib/appsignal/environment.rb +11 -2
  17. data/lib/appsignal/extension/jruby.rb +1 -1
  18. data/lib/appsignal/helpers/instrumentation.rb +164 -2
  19. data/lib/appsignal/hooks/active_job.rb +1 -6
  20. data/lib/appsignal/integrations/grape.rb +19 -47
  21. data/lib/appsignal/integrations/hanami.rb +8 -7
  22. data/lib/appsignal/integrations/padrino.rb +51 -52
  23. data/lib/appsignal/integrations/railtie.rb +0 -3
  24. data/lib/appsignal/integrations/rake.rb +46 -12
  25. data/lib/appsignal/integrations/sidekiq.rb +1 -11
  26. data/lib/appsignal/integrations/sinatra.rb +0 -1
  27. data/lib/appsignal/integrations/webmachine.rb +15 -9
  28. data/lib/appsignal/probes/gvl.rb +24 -2
  29. data/lib/appsignal/probes/sidekiq.rb +1 -1
  30. data/lib/appsignal/probes.rb +1 -1
  31. data/lib/appsignal/rack/abstract_middleware.rb +104 -33
  32. data/lib/appsignal/rack/body_wrapper.rb +143 -0
  33. data/lib/appsignal/rack/event_handler.rb +12 -3
  34. data/lib/appsignal/rack/generic_instrumentation.rb +5 -4
  35. data/lib/appsignal/rack/grape_middleware.rb +40 -0
  36. data/lib/appsignal/rack/hanami_middleware.rb +2 -12
  37. data/lib/appsignal/rack/instrumentation_middleware.rb +62 -0
  38. data/lib/appsignal/rack/rails_instrumentation.rb +14 -57
  39. data/lib/appsignal/rack/sinatra_instrumentation.rb +1 -3
  40. data/lib/appsignal/rack/streaming_listener.rb +13 -59
  41. data/lib/appsignal/rack.rb +31 -0
  42. data/lib/appsignal/transaction.rb +50 -8
  43. data/lib/appsignal/utils/integration_memory_logger.rb +78 -0
  44. data/lib/appsignal/utils.rb +1 -0
  45. data/lib/appsignal/version.rb +1 -1
  46. data/lib/appsignal.rb +36 -33
  47. data/spec/.rubocop.yml +1 -1
  48. data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
  49. data/spec/lib/appsignal/cli/install_spec.rb +3 -3
  50. data/spec/lib/appsignal/config_spec.rb +8 -5
  51. data/spec/lib/appsignal/demo_spec.rb +38 -41
  52. data/spec/lib/appsignal/hooks/action_cable_spec.rb +86 -167
  53. data/spec/lib/appsignal/hooks/active_support_notifications/finish_with_state_shared_examples.rb +8 -20
  54. data/spec/lib/appsignal/hooks/active_support_notifications/instrument_shared_examples.rb +38 -84
  55. data/spec/lib/appsignal/hooks/active_support_notifications/start_finish_shared_examples.rb +16 -37
  56. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +4 -4
  57. data/spec/lib/appsignal/hooks/activejob_spec.rb +111 -200
  58. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +54 -91
  59. data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +14 -32
  60. data/spec/lib/appsignal/hooks/excon_spec.rb +8 -12
  61. data/spec/lib/appsignal/hooks/net_http_spec.rb +7 -42
  62. data/spec/lib/appsignal/hooks/rake_spec.rb +107 -34
  63. data/spec/lib/appsignal/hooks/redis_client_spec.rb +18 -30
  64. data/spec/lib/appsignal/hooks/redis_spec.rb +10 -16
  65. data/spec/lib/appsignal/hooks/resque_spec.rb +42 -62
  66. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +33 -74
  67. data/spec/lib/appsignal/integrations/hanami_spec.rb +79 -21
  68. data/spec/lib/appsignal/integrations/http_spec.rb +12 -20
  69. data/spec/lib/appsignal/integrations/net_http_spec.rb +33 -0
  70. data/spec/lib/appsignal/integrations/object_spec.rb +29 -36
  71. data/spec/lib/appsignal/integrations/padrino_spec.rb +190 -163
  72. data/spec/lib/appsignal/integrations/que_spec.rb +43 -70
  73. data/spec/lib/appsignal/integrations/railtie_spec.rb +26 -67
  74. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +86 -160
  75. data/spec/lib/appsignal/integrations/sinatra_spec.rb +10 -3
  76. data/spec/lib/appsignal/integrations/webmachine_spec.rb +77 -40
  77. data/spec/lib/appsignal/probes/gvl_spec.rb +80 -3
  78. data/spec/lib/appsignal/probes_spec.rb +7 -4
  79. data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +302 -105
  80. data/spec/lib/appsignal/rack/body_wrapper_spec.rb +263 -0
  81. data/spec/lib/appsignal/rack/event_handler_spec.rb +81 -78
  82. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +70 -27
  83. data/spec/lib/appsignal/rack/grape_middleware_spec.rb +234 -0
  84. data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +2 -16
  85. data/spec/lib/appsignal/rack/instrumentation_middleware_spec.rb +38 -0
  86. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +67 -131
  87. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +36 -44
  88. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +44 -139
  89. data/spec/lib/appsignal/transaction_spec.rb +239 -94
  90. data/spec/lib/appsignal/utils/integration_memory_logger_spec.rb +163 -0
  91. data/spec/lib/appsignal_spec.rb +556 -344
  92. data/spec/support/helpers/dependency_helper.rb +6 -1
  93. data/spec/support/helpers/std_streams_helper.rb +1 -1
  94. data/spec/support/helpers/transaction_helpers.rb +8 -0
  95. data/spec/support/matchers/transaction.rb +185 -0
  96. data/spec/support/mocks/dummy_app.rb +20 -0
  97. data/spec/support/shared_examples/instrument.rb +17 -12
  98. data/spec/support/testing.rb +18 -9
  99. metadata +20 -11
  100. data/.semaphore/semaphore.yml +0 -2347
  101. data/script/lint_git +0 -22
  102. data/spec/lib/appsignal/integrations/grape_spec.rb +0 -239
  103. data/spec/support/matchers/be_completed.rb +0 -5
  104. data/support/check_versions +0 -22
  105. /data/gemfiles/{hanami.gemfile → hanami-2.0.gemfile} +0 -0
@@ -23,9 +23,8 @@ if DependencyHelper.http_present?
23
23
 
24
24
  HTTP.get("http://www.google.com")
25
25
 
26
- transaction_hash = transaction.to_h
27
- expect(transaction_hash).to include("namespace" => Appsignal::Transaction::HTTP_REQUEST)
28
- expect(transaction_hash["events"].first).to include(
26
+ expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
27
+ expect(transaction).to include_event(
29
28
  "body" => "",
30
29
  "body_format" => Appsignal::EventFormatter::DEFAULT,
31
30
  "name" => "request.http_rb",
@@ -38,9 +37,8 @@ if DependencyHelper.http_present?
38
37
 
39
38
  HTTP.get("https://www.google.com")
40
39
 
41
- transaction_hash = transaction.to_h
42
- expect(transaction_hash).to include("namespace" => Appsignal::Transaction::HTTP_REQUEST)
43
- expect(transaction_hash["events"].first).to include(
40
+ expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
41
+ expect(transaction).to include_event(
44
42
  "body" => "",
45
43
  "body_format" => Appsignal::EventFormatter::DEFAULT,
46
44
  "name" => "request.http_rb",
@@ -54,7 +52,7 @@ if DependencyHelper.http_present?
54
52
 
55
53
  HTTP.get("https://www.google.com", :params => { :q => "Appsignal" })
56
54
 
57
- expect(transaction.to_h["events"].first).to include(
55
+ expect(transaction).to include_event(
58
56
  "body" => "",
59
57
  "title" => "GET https://www.google.com"
60
58
  )
@@ -66,7 +64,7 @@ if DependencyHelper.http_present?
66
64
 
67
65
  HTTP.post("https://www.google.com", :json => { :q => "Appsignal" })
68
66
 
69
- expect(transaction.to_h["events"].first).to include(
67
+ expect(transaction).to include_event(
70
68
  "body" => "",
71
69
  "title" => "POST https://www.google.com"
72
70
  )
@@ -83,20 +81,14 @@ if DependencyHelper.http_present?
83
81
  HTTP.get("https://www.google.com")
84
82
  end.to raise_error(ExampleException)
85
83
 
86
- transaction_hash = transaction.to_h
87
- expect(transaction_hash).to include("namespace" => Appsignal::Transaction::HTTP_REQUEST)
88
- expect(transaction_hash["events"].first).to include(
84
+ expect(transaction).to have_namespace(Appsignal::Transaction::HTTP_REQUEST)
85
+ expect(transaction).to include_event(
89
86
  "body" => "",
90
87
  "body_format" => Appsignal::EventFormatter::DEFAULT,
91
88
  "name" => "request.http_rb",
92
89
  "title" => "GET https://www.google.com"
93
90
  )
94
-
95
- expect(transaction_hash["error"]).to include(
96
- "backtrace" => kind_of(String),
97
- "name" => error.class.name,
98
- "message" => error.message
99
- )
91
+ expect(transaction).to have_error(error.class.name, error.message)
100
92
  end
101
93
  end
102
94
 
@@ -112,7 +104,7 @@ if DependencyHelper.http_present?
112
104
 
113
105
  HTTP.get(request_uri.new("http://www.google.com"))
114
106
 
115
- expect(transaction.to_h["events"].first).to include(
107
+ expect(transaction).to include_event(
116
108
  "name" => "request.http_rb",
117
109
  "title" => "GET http://www.google.com"
118
110
  )
@@ -123,7 +115,7 @@ if DependencyHelper.http_present?
123
115
 
124
116
  HTTP.get(URI("http://www.google.com"))
125
117
 
126
- expect(transaction.to_h["events"].first).to include(
118
+ expect(transaction).to include_event(
127
119
  "name" => "request.http_rb",
128
120
  "title" => "GET http://www.google.com"
129
121
  )
@@ -134,7 +126,7 @@ if DependencyHelper.http_present?
134
126
 
135
127
  HTTP.get("http://www.google.com")
136
128
 
137
- expect(transaction.to_h["events"].first).to include(
129
+ expect(transaction).to include_event(
138
130
  "name" => "request.http_rb",
139
131
  "title" => "GET http://www.google.com"
140
132
  )
@@ -0,0 +1,33 @@
1
+ require "appsignal/integrations/net_http"
2
+
3
+ describe Appsignal::Integrations::NetHttpIntegration do
4
+ let(:transaction) { http_request_transaction }
5
+ before(:context) { start_agent }
6
+ before { set_current_transaction transaction }
7
+ around { |example| keep_transactions { example.run } }
8
+
9
+ it "instruments a http request" do
10
+ stub_request(:any, "http://www.google.com/")
11
+
12
+ Net::HTTP.get_response(URI.parse("http://www.google.com"))
13
+
14
+ expect(transaction).to include_event(
15
+ "name" => "request.net_http",
16
+ "title" => "GET http://www.google.com"
17
+ )
18
+ end
19
+
20
+ it "instruments a https request" do
21
+ stub_request(:any, "https://www.google.com/")
22
+
23
+ uri = URI.parse("https://www.google.com")
24
+ http = Net::HTTP.new(uri.host, uri.port)
25
+ http.use_ssl = true
26
+ http.get(uri.request_uri)
27
+
28
+ expect(transaction).to include_event(
29
+ "name" => "request.net_http",
30
+ "title" => "GET https://www.google.com"
31
+ )
32
+ end
33
+ end
@@ -1,6 +1,8 @@
1
1
  require "appsignal/integrations/object"
2
2
 
3
3
  describe Object do
4
+ around { |example| keep_transactions { example.run } }
5
+
4
6
  describe "#instrument_method" do
5
7
  context "with instance method" do
6
8
  let(:klass) do
@@ -24,10 +26,8 @@ describe Object do
24
26
  context "when active" do
25
27
  let(:transaction) { http_request_transaction }
26
28
  before do
27
- Appsignal.config = project_fixture_config
28
- expect(Appsignal::Transaction).to receive(:current)
29
- .at_least(:once).and_return(transaction)
30
- expect(Appsignal.active?).to be_truthy
29
+ start_agent
30
+ set_current_transaction(transaction)
31
31
  end
32
32
  after { Appsignal.config = nil }
33
33
 
@@ -80,10 +80,9 @@ describe Object do
80
80
 
81
81
  context "with anonymous class" do
82
82
  it "instruments the method and calls it" do
83
- expect(transaction).to receive(:start_event)
84
- expect(transaction).to receive(:finish_event).with \
85
- "foo.AnonymousClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
86
83
  expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
84
+
85
+ expect(transaction).to include_event("name" => "foo.AnonymousClass.other")
87
86
  end
88
87
  end
89
88
 
@@ -100,10 +99,9 @@ describe Object do
100
99
  let(:klass) { NamedClass }
101
100
 
102
101
  it "instruments the method and calls it" do
103
- expect(transaction).to receive(:start_event)
104
- expect(transaction).to receive(:finish_event).with \
105
- "foo.NamedClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
106
102
  expect(instance.foo).to eq(1)
103
+
104
+ expect(transaction).to include_event("name" => "foo.NamedClass.other")
107
105
  end
108
106
  end
109
107
 
@@ -124,11 +122,11 @@ describe Object do
124
122
  let(:klass) { MyModule::NestedModule::NamedClass }
125
123
 
126
124
  it "instruments the method and calls it" do
127
- expect(transaction).to receive(:start_event)
128
- expect(transaction).to receive(:finish_event).with \
129
- "bar.NamedClass.NestedModule.MyModule.other", nil, nil,
130
- Appsignal::EventFormatter::DEFAULT
131
125
  expect(instance.bar).to eq(2)
126
+
127
+ expect(transaction).to include_event(
128
+ "name" => "bar.NamedClass.NestedModule.MyModule.other"
129
+ )
132
130
  end
133
131
  end
134
132
 
@@ -143,10 +141,11 @@ describe Object do
143
141
  end
144
142
 
145
143
  it "instruments with custom name" do
146
- expect(transaction).to receive(:start_event)
147
- expect(transaction).to receive(:finish_event).with \
148
- "my_method.group", nil, nil, Appsignal::EventFormatter::DEFAULT
149
144
  expect(instance.foo).to eq(1)
145
+
146
+ expect(transaction).to include_event(
147
+ "name" => "my_method.group"
148
+ )
150
149
  end
151
150
  end
152
151
 
@@ -160,7 +159,7 @@ describe Object do
160
159
  end
161
160
  end
162
161
 
163
- it "should yield the block" do
162
+ it "yields the block" do
164
163
  expect(instance.foo { 42 }).to eq(42)
165
164
  end
166
165
  end
@@ -171,7 +170,6 @@ describe Object do
171
170
 
172
171
  it "does not instrument, but still calls the method" do
173
172
  expect(Appsignal.active?).to be_falsy
174
- expect(transaction).to_not receive(:start_event)
175
173
  expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
176
174
  end
177
175
  end
@@ -198,8 +196,7 @@ describe Object do
198
196
  let(:transaction) { http_request_transaction }
199
197
  before do
200
198
  Appsignal.config = project_fixture_config
201
- expect(Appsignal::Transaction).to receive(:current).at_least(:once)
202
- .and_return(transaction)
199
+ set_current_transaction(transaction)
203
200
  end
204
201
  after { Appsignal.config = nil }
205
202
 
@@ -253,10 +250,10 @@ describe Object do
253
250
  context "with anonymous class" do
254
251
  it "instruments the method and calls it" do
255
252
  expect(Appsignal.active?).to be_truthy
256
- expect(transaction).to receive(:start_event)
257
- expect(transaction).to receive(:finish_event).with \
258
- "bar.class_method.AnonymousClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
259
253
  expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
254
+
255
+ transaction._sample
256
+ expect(transaction).to include_event("name" => "bar.class_method.AnonymousClass.other")
260
257
  end
261
258
  end
262
259
 
@@ -274,10 +271,9 @@ describe Object do
274
271
 
275
272
  it "instruments the method and calls it" do
276
273
  expect(Appsignal.active?).to be_truthy
277
- expect(transaction).to receive(:start_event)
278
- expect(transaction).to receive(:finish_event).with \
279
- "bar.class_method.NamedClass.other", nil, nil, Appsignal::EventFormatter::DEFAULT
280
274
  expect(klass.bar).to eq(2)
275
+
276
+ expect(transaction).to include_event("name" => "bar.class_method.NamedClass.other")
281
277
  end
282
278
 
283
279
  context "with nested named class" do
@@ -298,11 +294,10 @@ describe Object do
298
294
 
299
295
  it "instruments the method and calls it" do
300
296
  expect(Appsignal.active?).to be_truthy
301
- expect(transaction).to receive(:start_event)
302
- expect(transaction).to receive(:finish_event).with \
303
- "bar.class_method.NamedClass.NestedModule.MyModule.other", nil, nil,
304
- Appsignal::EventFormatter::DEFAULT
305
297
  expect(klass.bar).to eq(2)
298
+ expect(transaction).to include_event(
299
+ "name" => "bar.class_method.NamedClass.NestedModule.MyModule.other"
300
+ )
306
301
  end
307
302
  end
308
303
  end
@@ -319,10 +314,9 @@ describe Object do
319
314
 
320
315
  it "instruments with custom name" do
321
316
  expect(Appsignal.active?).to be_truthy
322
- expect(transaction).to receive(:start_event)
323
- expect(transaction).to receive(:finish_event).with \
324
- "my_method.group", nil, nil, Appsignal::EventFormatter::DEFAULT
325
317
  expect(klass.bar).to eq(2)
318
+
319
+ expect(transaction).to include_event("name" => "my_method.group")
326
320
  end
327
321
  end
328
322
 
@@ -336,7 +330,7 @@ describe Object do
336
330
  end
337
331
  end
338
332
 
339
- it "should yield the block" do
333
+ it "yields the block" do
340
334
  expect(klass.bar { 42 }).to eq(42)
341
335
  end
342
336
  end
@@ -347,7 +341,6 @@ describe Object do
347
341
 
348
342
  it "does not instrument, but still call the method" do
349
343
  expect(Appsignal.active?).to be_falsy
350
- expect(transaction).to_not receive(:start_event)
351
344
  expect(call_with_arguments).to eq(["abc", { :foo => "bar" }, 2])
352
345
  end
353
346
  end