appsignal 3.9.2-java → 3.9.3-java

Sign up to get free protection for your applications and to get access to all the features.
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
data/script/lint_git DELETED
@@ -1,22 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -eu
4
-
5
- LINTJE_VERSION="0.11.3"
6
-
7
- mkdir -p "$HOME/bin"
8
- cache_key=v1-lintje-$LINTJE_VERSION
9
- cache restore $cache_key
10
-
11
- # File exists and is executable
12
- if [ -x "$HOME/bin/lintje" ]; then
13
- echo "Restored Lintje $LINTJE_VERSION from cache"
14
- else
15
- echo "Downloading Lintje $LINTJE_VERSION"
16
- curl -L \
17
- https://github.com/tombruijn/lintje/releases/download/v$LINTJE_VERSION/x86_64-unknown-linux-gnu.tar.gz | \
18
- tar -xz --directory "$HOME/bin"
19
- cache store $cache_key "$HOME/bin/lintje"
20
- fi
21
-
22
- "$HOME/bin/lintje" "$SEMAPHORE_GIT_COMMIT_RANGE"
@@ -1,239 +0,0 @@
1
- if DependencyHelper.grape_present?
2
- require "appsignal/integrations/grape"
3
-
4
- describe Appsignal::Grape::Middleware do
5
- let(:app) do
6
- Class.new(::Grape::API) do
7
- format :json
8
- post :ping do
9
- { :message => "Hello world!" }
10
- end
11
- end
12
- end
13
- let(:api_endpoint) { app.endpoints.first }
14
- let(:env) do
15
- http_request_env_with_data \
16
- "api.endpoint" => api_endpoint,
17
- "REQUEST_METHOD" => "POST",
18
- :path => "/ping"
19
- end
20
- let(:middleware) { Appsignal::Grape::Middleware.new(api_endpoint) }
21
- around do |example|
22
- GrapeExample = Module.new
23
- GrapeExample.send(:const_set, :Api, app)
24
- example.run
25
- Object.send(:remove_const, :GrapeExample)
26
- end
27
-
28
- describe "#call" do
29
- context "when AppSignal is not active" do
30
- before(:context) do
31
- Appsignal.config = nil
32
- Appsignal::Hooks.load_hooks
33
- end
34
-
35
- it "creates no transaction" do
36
- expect(Appsignal::Transaction).to_not receive(:create)
37
- end
38
-
39
- it "calls the endpoint normally" do
40
- expect(api_endpoint).to receive(:call).with(env)
41
- end
42
-
43
- after { middleware.call(env) }
44
- end
45
-
46
- context "when AppSignal is active" do
47
- let(:transaction) { http_request_transaction }
48
- before :context do
49
- Appsignal.config = project_fixture_config
50
- expect(Appsignal.active?).to be_truthy
51
- end
52
- before do
53
- expect(Appsignal::Transaction).to receive(:create).with(
54
- kind_of(String),
55
- Appsignal::Transaction::HTTP_REQUEST,
56
- kind_of(::Rack::Request)
57
- ).and_return(transaction)
58
- end
59
-
60
- context "without error" do
61
- it "calls the endpoint" do
62
- expect(api_endpoint).to receive(:call).with(env)
63
- end
64
-
65
- it "sets metadata" do
66
- expect(transaction).to receive(:set_http_or_background_queue_start)
67
- expect(transaction).to receive(:set_action_if_nil).with("POST::GrapeExample::Api#/ping")
68
- expect(transaction).to receive(:set_metadata).with("path", "/ping")
69
- expect(transaction).to receive(:set_metadata).with("method", "POST")
70
- end
71
-
72
- after { middleware.call(env) }
73
- end
74
-
75
- context "with error" do
76
- let(:app) do
77
- Class.new(::Grape::API) do
78
- format :json
79
- post :ping do
80
- raise ExampleException
81
- end
82
- end
83
- end
84
-
85
- it "sets metadata" do
86
- expect(transaction).to receive(:set_http_or_background_queue_start)
87
- expect(transaction).to receive(:set_action_if_nil).with("POST::GrapeExample::Api#/ping")
88
- expect(transaction).to receive(:set_metadata).with("path", "/ping")
89
- expect(transaction).to receive(:set_metadata).with("method", "POST")
90
- end
91
-
92
- it "sets the error" do
93
- expect(transaction).to receive(:set_error).with(kind_of(ExampleException))
94
- end
95
-
96
- context "with env['grape.skip_appsignal_error'] = true" do
97
- before do
98
- env["grape.skip_appsignal_error"] = true
99
- end
100
-
101
- it "does not add the error" do
102
- expect(transaction).to_not receive(:set_error)
103
- end
104
- end
105
-
106
- after do
107
- expect { middleware.call(env) }.to raise_error ExampleException
108
- end
109
- end
110
-
111
- context "with route" do
112
- let(:app) do
113
- Class.new(::Grape::API) do
114
- route([:get, :post], "hello") do
115
- "Hello!"
116
- end
117
- end
118
- end
119
- let(:env) do
120
- http_request_env_with_data \
121
- "api.endpoint" => api_endpoint,
122
- "REQUEST_METHOD" => "GET",
123
- :path => ""
124
- end
125
-
126
- it "sets non-unique route path" do
127
- expect(transaction).to receive(:set_action).with("GET::GrapeExample::Api#/hello")
128
- expect(transaction).to receive(:set_metadata).with("path", "/hello")
129
- expect(transaction).to receive(:set_metadata).with("method", "GET")
130
- end
131
-
132
- after { middleware.call(env) }
133
- end
134
-
135
- context "with route_param" do
136
- let(:app) do
137
- Class.new(::Grape::API) do
138
- format :json
139
- resource :users do
140
- route_param :id do
141
- get do
142
- { :name => "Tom" }
143
- end
144
- end
145
- end
146
- end
147
- end
148
- let(:env) do
149
- http_request_env_with_data \
150
- "api.endpoint" => api_endpoint,
151
- "REQUEST_METHOD" => "GET",
152
- :path => ""
153
- end
154
-
155
- it "sets non-unique route_param path" do
156
- expect(transaction).to receive(:set_action_if_nil)
157
- .with("GET::GrapeExample::Api#/users/:id/")
158
- expect(transaction).to receive(:set_metadata).with("path", "/users/:id/")
159
- expect(transaction).to receive(:set_metadata).with("method", "GET")
160
- end
161
-
162
- after { middleware.call(env) }
163
- end
164
-
165
- context "with namespaced path" do
166
- context "with symbols" do
167
- let(:app) do
168
- Class.new(::Grape::API) do
169
- format :json
170
- namespace :v1 do
171
- namespace :beta do
172
- post :ping do
173
- { :message => "Hello namespaced world!" }
174
- end
175
- end
176
- end
177
- end
178
- end
179
-
180
- it "sets namespaced path" do
181
- expect(transaction).to receive(:set_action_if_nil)
182
- .with("POST::GrapeExample::Api#/v1/beta/ping")
183
- expect(transaction).to receive(:set_metadata).with("path", "/v1/beta/ping")
184
- expect(transaction).to receive(:set_metadata).with("method", "POST")
185
- end
186
- end
187
-
188
- context "with strings" do
189
- context "without / prefix" do
190
- let(:app) do
191
- Class.new(::Grape::API) do
192
- format :json
193
- namespace "v1" do
194
- namespace "beta" do
195
- post "ping" do
196
- { :message => "Hello namespaced world!" }
197
- end
198
- end
199
- end
200
- end
201
- end
202
-
203
- it "sets namespaced path" do
204
- expect(transaction).to receive(:set_action_if_nil)
205
- .with("POST::GrapeExample::Api#/v1/beta/ping")
206
- expect(transaction).to receive(:set_metadata).with("path", "/v1/beta/ping")
207
- expect(transaction).to receive(:set_metadata).with("method", "POST")
208
- end
209
- end
210
-
211
- context "with / prefix" do
212
- let(:app) do
213
- Class.new(::Grape::API) do
214
- format :json
215
- namespace "/v1" do
216
- namespace "/beta" do
217
- post "/ping" do
218
- { :message => "Hello namespaced world!" }
219
- end
220
- end
221
- end
222
- end
223
- end
224
-
225
- it "sets namespaced path" do
226
- expect(transaction).to receive(:set_action_if_nil)
227
- .with("POST::GrapeExample::Api#/v1/beta/ping")
228
- expect(transaction).to receive(:set_metadata).with("path", "/v1/beta/ping")
229
- expect(transaction).to receive(:set_metadata).with("method", "POST")
230
- end
231
- end
232
- end
233
-
234
- after { middleware.call(env) }
235
- end
236
- end
237
- end
238
- end
239
- end
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :be_completed do
2
- match do |transaction|
3
- values_match? transaction.ext._completed?, true
4
- end
5
- end
File without changes