appsignal 2.11.7 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.rubocop_todo.yml +1 -1
  4. data/.semaphore/semaphore.yml +88 -111
  5. data/CHANGELOG.md +23 -0
  6. data/appsignal.gemspec +1 -1
  7. data/build_matrix.yml +11 -15
  8. data/lib/appsignal.rb +2 -29
  9. data/lib/appsignal/auth_check.rb +2 -8
  10. data/lib/appsignal/cli.rb +1 -23
  11. data/lib/appsignal/config.rb +0 -24
  12. data/lib/appsignal/event_formatter.rb +0 -25
  13. data/lib/appsignal/helpers/instrumentation.rb +69 -5
  14. data/lib/appsignal/hooks.rb +6 -13
  15. data/lib/appsignal/hooks/action_cable.rb +3 -34
  16. data/lib/appsignal/hooks/active_support_notifications.rb +7 -86
  17. data/lib/appsignal/hooks/celluloid.rb +5 -9
  18. data/lib/appsignal/hooks/net_http.rb +2 -12
  19. data/lib/appsignal/hooks/puma.rb +3 -5
  20. data/lib/appsignal/hooks/que.rb +1 -1
  21. data/lib/appsignal/hooks/rake.rb +2 -24
  22. data/lib/appsignal/hooks/redis.rb +2 -13
  23. data/lib/appsignal/hooks/resque.rb +2 -43
  24. data/lib/appsignal/hooks/sidekiq.rb +6 -143
  25. data/lib/appsignal/hooks/unicorn.rb +3 -24
  26. data/lib/appsignal/hooks/webmachine.rb +1 -7
  27. data/lib/appsignal/integrations/action_cable.rb +34 -0
  28. data/lib/appsignal/integrations/active_support_notifications.rb +77 -0
  29. data/lib/appsignal/integrations/net_http.rb +16 -0
  30. data/lib/appsignal/integrations/object.rb +39 -4
  31. data/lib/appsignal/integrations/padrino.rb +5 -7
  32. data/lib/appsignal/integrations/que.rb +26 -33
  33. data/lib/appsignal/integrations/railtie.rb +1 -4
  34. data/lib/appsignal/integrations/rake.rb +26 -2
  35. data/lib/appsignal/integrations/redis.rb +17 -0
  36. data/lib/appsignal/integrations/resque.rb +39 -10
  37. data/lib/appsignal/integrations/sidekiq.rb +171 -0
  38. data/lib/appsignal/integrations/unicorn.rb +28 -0
  39. data/lib/appsignal/integrations/webmachine.rb +22 -24
  40. data/lib/appsignal/minutely.rb +6 -12
  41. data/lib/appsignal/version.rb +1 -1
  42. data/spec/lib/appsignal/auth_check_spec.rb +1 -24
  43. data/spec/lib/appsignal/cli_spec.rb +1 -1
  44. data/spec/lib/appsignal/config_spec.rb +0 -66
  45. data/spec/lib/appsignal/event_formatter_spec.rb +0 -37
  46. data/spec/lib/appsignal/hooks/celluloid_spec.rb +6 -1
  47. data/spec/lib/appsignal/hooks/rake_spec.rb +1 -2
  48. data/spec/lib/appsignal/hooks/redis_spec.rb +50 -15
  49. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +12 -464
  50. data/spec/lib/appsignal/hooks/unicorn_spec.rb +14 -3
  51. data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -13
  52. data/spec/lib/appsignal/hooks_spec.rb +6 -22
  53. data/spec/lib/appsignal/integrations/object_spec.rb +91 -8
  54. data/spec/lib/appsignal/integrations/padrino_spec.rb +2 -3
  55. data/spec/lib/appsignal/integrations/railtie_spec.rb +0 -45
  56. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +524 -0
  57. data/spec/lib/appsignal/integrations/webmachine_spec.rb +26 -8
  58. data/spec/lib/appsignal/minutely_spec.rb +0 -19
  59. data/spec/lib/appsignal/transaction_spec.rb +1 -14
  60. data/spec/lib/appsignal/transmitter_spec.rb +1 -1
  61. data/spec/lib/appsignal_spec.rb +162 -116
  62. data/spec/lib/puma/appsignal_spec.rb +28 -0
  63. data/spec/spec_helper.rb +1 -15
  64. metadata +11 -21
  65. data/lib/appsignal/cli/notify_of_deploy.rb +0 -131
  66. data/lib/appsignal/integrations/object_ruby_19.rb +0 -37
  67. data/lib/appsignal/integrations/object_ruby_modern.rb +0 -64
  68. data/lib/appsignal/integrations/resque_active_job.rb +0 -19
  69. data/lib/appsignal/js_exception_transaction.rb +0 -56
  70. data/lib/appsignal/rack/js_exception_catcher.rb +0 -80
  71. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +0 -180
  72. data/spec/lib/appsignal/integrations/object_19_spec.rb +0 -266
  73. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +0 -28
  74. data/spec/lib/appsignal/integrations/resque_spec.rb +0 -28
  75. data/spec/lib/appsignal/js_exception_transaction_spec.rb +0 -128
  76. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +0 -170
@@ -1,28 +0,0 @@
1
- require "appsignal/integrations/resque_active_job"
2
-
3
- describe "Legacy Resque ActiveJob integration" do
4
- let(:err_stream) { std_stream }
5
- let(:stderr) { err_stream.read }
6
- let(:log_stream) { std_stream }
7
- let(:log) { log_contents(log_stream) }
8
-
9
- it "logs and prints a deprecation message on extend" do
10
- Appsignal.logger = test_logger(log_stream)
11
-
12
- capture_std_streams(std_stream, err_stream) do
13
- Class.new do
14
- include Appsignal::Integrations::ResqueActiveJobPlugin
15
- end
16
- end
17
-
18
- deprecation_message =
19
- "The AppSignal ResqueActiveJobPlugin is deprecated and does " \
20
- "nothing on extend. In this version of the AppSignal Ruby gem " \
21
- "the integration with Resque is automatic on all Resque workers. " \
22
- "Please remove the following line from this file to remove this " \
23
- "message: include Appsignal::Integrations::ResqueActiveJobPlugin\n" \
24
- "#{__FILE__}:"
25
- expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
26
- expect(log).to contains_log :warn, deprecation_message
27
- end
28
- end
@@ -1,28 +0,0 @@
1
- require "appsignal/integrations/resque"
2
-
3
- describe "Legacy Resque integration" do
4
- let(:err_stream) { std_stream }
5
- let(:stderr) { err_stream.read }
6
- let(:log_stream) { std_stream }
7
- let(:log) { log_contents(log_stream) }
8
-
9
- it "logs and prints a deprecation message on extend" do
10
- Appsignal.logger = test_logger(log_stream)
11
-
12
- capture_std_streams(std_stream, err_stream) do
13
- Class.new do
14
- extend Appsignal::Integrations::ResquePlugin
15
- end
16
- end
17
-
18
- deprecation_message =
19
- "The AppSignal ResquePlugin is deprecated and does " \
20
- "nothing on extend. In this version of the AppSignal Ruby gem " \
21
- "the integration with Resque is automatic on all Resque workers. " \
22
- "Please remove the following line from this file to remove this " \
23
- "message: extend Appsignal::Integrations::ResquePlugin\n" \
24
- "#{__FILE__}:"
25
- expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
26
- expect(log).to contains_log :warn, deprecation_message
27
- end
28
- end
@@ -1,128 +0,0 @@
1
- describe Appsignal::JSExceptionTransaction do
2
- before { allow(SecureRandom).to receive(:uuid).and_return("123abc") }
3
-
4
- let!(:transaction) { Appsignal::JSExceptionTransaction.new(data) }
5
- let(:data) do
6
- {
7
- "name" => "TypeError",
8
- "message" => "foo is not a valid method",
9
- "action" => "ExceptionIncidentComponent",
10
- "path" => "foo.bar/moo",
11
- "environment" => "development",
12
- "backtrace" => [
13
- "foo.bar/js:11:1",
14
- "foo.bar/js:22:2"
15
- ],
16
- "tags" => [
17
- "tag1"
18
- ]
19
- }
20
- end
21
-
22
- describe "#initialize" do
23
- it "should call all required methods" do
24
- expect(Appsignal::Extension).to receive(:start_transaction).with("123abc", "frontend", 0).and_return(1)
25
-
26
- expect(transaction).to receive(:set_action)
27
- expect(transaction).to receive(:set_metadata)
28
- expect(transaction).to receive(:set_error)
29
- expect(transaction).to receive(:set_sample_data)
30
-
31
- transaction.send :initialize, data
32
-
33
- expect(transaction.ext).to_not be_nil
34
- end
35
- end
36
-
37
- describe "#set_action" do
38
- it "should call `Appsignal::Extension.set_action`" do
39
- expect(transaction.ext).to receive(:set_action).with(
40
- "ExceptionIncidentComponent"
41
- )
42
-
43
- transaction.set_action
44
- end
45
- end
46
-
47
- describe "#set_metadata" do
48
- it "should call `Appsignal::Extension.set_transaction_metadata`" do
49
- expect(transaction.ext).to receive(:set_metadata).with(
50
- "path",
51
- "foo.bar/moo"
52
- )
53
-
54
- transaction.set_metadata
55
- end
56
- end
57
-
58
- describe "#set_error" do
59
- it "should call `Appsignal::Extension.set_transaction_error`" do
60
- expect(transaction.ext).to receive(:set_error).with(
61
- "TypeError",
62
- "foo is not a valid method",
63
- Appsignal::Utils::Data.generate(["foo.bar/js:11:1", "foo.bar/js:22:2"])
64
- )
65
-
66
- transaction.set_error
67
- end
68
- end
69
-
70
- describe "#set_sample_data" do
71
- it "should call `Appsignal::Extension.set_transaction_error_data`" do
72
- expect(transaction.ext).to receive(:set_sample_data).with(
73
- "tags",
74
- Appsignal::Utils::Data.generate(["tag1"])
75
- )
76
-
77
- transaction.set_sample_data
78
- end
79
- end
80
-
81
- context "when sending just the name" do
82
- let(:data) { { "name" => "TypeError" } }
83
-
84
- describe "#set_action" do
85
- it "should not call `Appsignal::Extension.set_action`" do
86
- expect(transaction.ext).to_not receive(:set_action)
87
-
88
- transaction.set_action
89
- end
90
- end
91
-
92
- describe "#set_metadata" do
93
- it "should not call `Appsignal::Extension.set_transaction_metadata`" do
94
- expect(transaction.ext).to_not receive(:set_metadata)
95
-
96
- transaction.set_metadata
97
- end
98
- end
99
-
100
- describe "#set_error" do
101
- it "should call `Appsignal::Extension.set_transaction_error` with just the name" do
102
- expect(transaction.ext).to receive(:set_error).with(
103
- "TypeError",
104
- "",
105
- Appsignal::Utils::Data.generate([])
106
- )
107
-
108
- transaction.set_error
109
- end
110
- end
111
-
112
- describe "#set_sample_data" do
113
- it "should not call `Appsignal::Extension.set_transaction_error_data`" do
114
- expect(transaction.ext).to_not receive(:set_sample_data)
115
-
116
- transaction.set_sample_data
117
- end
118
- end
119
- end
120
-
121
- describe "#complete!" do
122
- it "should call all required methods" do
123
- expect(transaction.ext).to receive(:finish).and_call_original
124
- expect(transaction.ext).to receive(:complete).and_call_original
125
- transaction.complete!
126
- end
127
- end
128
- end
@@ -1,170 +0,0 @@
1
- describe Appsignal::Rack::JSExceptionCatcher do
2
- let(:app) { double(:call => true) }
3
- let(:options) { nil }
4
- let(:config_options) { { :enable_frontend_error_catching => true } }
5
- let(:config) { project_fixture_config("production", config_options) }
6
- let(:deprecation_message) do
7
- "The Appsignal::Rack::JSExceptionCatcher is " \
8
- "deprecated and will be removed in a future version. Please use " \
9
- "the official AppSignal JavaScript integration by disabling " \
10
- "`enable_frontend_error_catching` in your configuration and " \
11
- "installing AppSignal for JavaScript instead. " \
12
- "(https://docs.appsignal.com/front-end/)"
13
- end
14
- before { Appsignal.config = config }
15
-
16
- describe "#initialize" do
17
- let(:out_stream) { std_stream }
18
- let(:err_stream) { std_stream }
19
- let(:output) { out_stream.read }
20
- let(:stderr) { err_stream.read }
21
-
22
- it "logs to the logger" do
23
- log = capture_logs do
24
- capture_std_streams(out_stream, err_stream) do
25
- Appsignal::Rack::JSExceptionCatcher.new(app, options)
26
- end
27
- end
28
- expect(log).to contains_log(:warn, deprecation_message)
29
- expect(log).to contains_log(:debug, "Initializing Appsignal::Rack::JSExceptionCatcher")
30
- expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
31
- expect(stderr).to_not include("appsignal:")
32
- expect(output).to be_empty
33
- end
34
- end
35
-
36
- describe "#call" do
37
- let(:catcher) do
38
- silence :allowed => ["enable_frontend_error_catching"] do
39
- Appsignal::Rack::JSExceptionCatcher.new(app, options)
40
- end
41
- end
42
- after { catcher.call(env) }
43
-
44
- context "when path is not frontend_error_catching_path" do
45
- let(:env) { { "PATH_INFO" => "/foo" } }
46
-
47
- context "when AppSignal is not active" do
48
- before { config[:active] = false }
49
-
50
- it "calls the next middleware" do
51
- expect(app).to receive(:call).with(env)
52
- end
53
- end
54
-
55
- context "when AppSignal is active" do
56
- before { config[:active] = true }
57
-
58
- it "calls the next middleware" do
59
- expect(app).to receive(:call).with(env)
60
- end
61
- end
62
- end
63
-
64
- context "when path is frontend_error_catching_path" do
65
- let(:transaction) { double(:complete! => true) }
66
- let(:env) do
67
- {
68
- "PATH_INFO" => "/appsignal_error_catcher",
69
- "rack.input" => double(:read => '{"name": "error"}')
70
- }
71
- end
72
-
73
- context "when AppSignal is not active" do
74
- before { config[:active] = false }
75
-
76
- it "doesn't create an AppSignal transaction" do
77
- expect(Appsignal::JSExceptionTransaction).to_not receive(:new)
78
- end
79
-
80
- it "returns a 202 status" do
81
- expect(catcher.call(env)).to eq(
82
- [202, {}, ["AppSignal JavaScript error catching endpoint is not active."]]
83
- )
84
- end
85
- end
86
-
87
- context "when AppSignal is active" do
88
- before { config[:active] = true }
89
-
90
- it "creates a JSExceptionTransaction" do
91
- expect(Appsignal::JSExceptionTransaction).to receive(:new)
92
- .with("name" => "error")
93
- .and_return(transaction)
94
-
95
- expect(transaction).to receive(:complete!)
96
- end
97
-
98
- it "returns 200" do
99
- allow(Appsignal::JSExceptionTransaction).to receive(:new)
100
- .and_return(transaction)
101
-
102
- expect(catcher.call(env)).to eq([200, {}, []])
103
- end
104
-
105
- context "when request payload is empty" do
106
- let(:env) do
107
- {
108
- "PATH_INFO" => "/appsignal_error_catcher",
109
- "rack.input" => double(:read => "")
110
- }
111
- end
112
-
113
- it "does not create a transaction" do
114
- expect(Appsignal::JSExceptionTransaction).to_not receive(:new)
115
- end
116
-
117
- it "returns 400" do
118
- expect(catcher.call(env)).to eq([400, {}, ["Request payload is not valid JSON."]])
119
- end
120
- end
121
-
122
- context "when `frontend_error_catching_path` is different" do
123
- let(:config_options) { { :frontend_error_catching_path => "/foo" } }
124
-
125
- it "does not create a transaction" do
126
- expect(Appsignal::JSExceptionTransaction).to_not receive(:new)
127
- end
128
-
129
- it "calls the next middleware" do
130
- expect(app).to receive(:call).with(env)
131
- end
132
- end
133
-
134
- context "when `name` is empty" do
135
- let(:env) do
136
- {
137
- "PATH_INFO" => "/appsignal_error_catcher",
138
- "rack.input" => double(:read => '{"name": ""}')
139
- }
140
- end
141
-
142
- it "does not create a transaction" do
143
- expect(Appsignal::JSExceptionTransaction).to_not receive(:new)
144
- end
145
-
146
- it "returns 422" do
147
- expect(catcher.call(env)).to eq([422, {}, []])
148
- end
149
- end
150
-
151
- context "when `name` doesn't exist" do
152
- let(:env) do
153
- {
154
- "PATH_INFO" => "/appsignal_error_catcher",
155
- "rack.input" => double(:read => '{"foo": ""}')
156
- }
157
- end
158
-
159
- it "does not create a transaction" do
160
- expect(Appsignal::JSExceptionTransaction).to_not receive(:new)
161
- end
162
-
163
- it "returns 422" do
164
- expect(catcher.call(env)).to eq([422, {}, []])
165
- end
166
- end
167
- end
168
- end
169
- end
170
- end