appsignal 1.3.6.beta.1 → 1.3.6
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.
- checksums.yaml +4 -4
- data/lib/appsignal/js_exception_transaction.rb +1 -0
- data/lib/appsignal/marker.rb +3 -2
- data/lib/appsignal/transmitter.rb +2 -4
- data/lib/appsignal/utils.rb +6 -0
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/capistrano2_spec.rb +67 -77
- data/spec/lib/appsignal/capistrano3_spec.rb +54 -66
- data/spec/lib/appsignal/marker_spec.rb +33 -40
- data/spec/lib/appsignal/transmitter_spec.rb +2 -6
- data/spec/lib/appsignal/utils/gzip_spec.rb +10 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/helpers/api_request_helper.rb +19 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66a5631dc247e540f18fdb0d2e212d3c8125fd95
|
4
|
+
data.tar.gz: b6aad615e011a4bdd7392f5ea9d0c528f0432d2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 658ef073b6ba0ed43d3cef4f1ea110a22cdbf048985e514f3f0111b7d084df8dccfe6272f95cb5ca4aa1e976f9f8c60788157ee2796dcb5416ec4aaef8a21a70
|
7
|
+
data.tar.gz: abf3ae40acc98613930b7b05d1b42a130defcca4e1fdcb2e4a1a9b6e871d4f92de625d54a0b65de9a957edbca6bce396c6b605045ac6fe9d32f93f5da1eba832
|
data/lib/appsignal/marker.rb
CHANGED
@@ -10,14 +10,15 @@ module Appsignal
|
|
10
10
|
|
11
11
|
def transmit
|
12
12
|
transmitter = Transmitter.new(ACTION, config)
|
13
|
-
puts "Notifying Appsignal of deploy with:
|
13
|
+
puts "Notifying Appsignal of deploy with: "\
|
14
|
+
"revision: #{marker_data[:revision]}, user: #{marker_data[:user]}"
|
14
15
|
result = transmitter.transmit(marker_data)
|
15
16
|
if result == '200'
|
16
17
|
puts 'Appsignal has been notified of this deploy!'
|
17
18
|
else
|
18
19
|
raise "#{result} at #{transmitter.uri}"
|
19
20
|
end
|
20
|
-
rescue
|
21
|
+
rescue => e
|
21
22
|
puts "Something went wrong while trying to notify Appsignal: #{e}"
|
22
23
|
end
|
23
24
|
end
|
@@ -51,10 +51,8 @@ module Appsignal
|
|
51
51
|
Net::HTTP::Post.new(uri.request_uri).tap do |request|
|
52
52
|
request['Content-Type'] = CONTENT_TYPE
|
53
53
|
request['Content-Encoding'] = CONTENT_ENCODING
|
54
|
-
request.body =
|
55
|
-
Appsignal::Utils.
|
56
|
-
Zlib::BEST_SPEED
|
57
|
-
)
|
54
|
+
request.body = Appsignal::Utils::Gzip.compress \
|
55
|
+
Appsignal::Utils::JSON.generate(payload)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
data/lib/appsignal/utils.rb
CHANGED
data/lib/appsignal/version.rb
CHANGED
@@ -6,33 +6,36 @@ if capistrano2_present?
|
|
6
6
|
describe "Capistrano 2 integration" do
|
7
7
|
let(:out_stream) { StringIO.new }
|
8
8
|
let(:config) { project_fixture_config }
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
let(:capistrano_config) do
|
10
|
+
Capistrano::Configuration.new.tap do |c|
|
11
|
+
c.set(:rails_env, 'production')
|
12
|
+
c.set(:repository, 'master')
|
13
|
+
c.set(:deploy_to, '/home/username/app')
|
14
|
+
c.set(:current_release, '')
|
15
|
+
c.set(:current_revision, '503ce0923ed177a3ce000005')
|
16
|
+
c.dry_run = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
before do
|
20
|
+
Appsignal::Capistrano.tasks(capistrano_config)
|
12
21
|
end
|
13
22
|
around do |example|
|
14
23
|
capture_stdout(out_stream) { example.run }
|
15
24
|
end
|
16
25
|
|
17
26
|
it "should have a deploy task" do
|
18
|
-
|
27
|
+
capistrano_config.find_task('appsignal:deploy').should_not be_nil
|
19
28
|
end
|
20
29
|
|
21
30
|
describe "appsignal:deploy task" do
|
22
31
|
before do
|
23
|
-
@capistrano_config.set(:rails_env, 'production')
|
24
|
-
@capistrano_config.set(:repository, 'master')
|
25
|
-
@capistrano_config.set(:deploy_to, '/home/username/app')
|
26
|
-
@capistrano_config.set(:current_release, '')
|
27
|
-
@capistrano_config.set(:current_revision, '503ce0923ed177a3ce000005')
|
28
|
-
@capistrano_config.dry_run = false
|
29
32
|
ENV['USER'] = 'batman'
|
30
33
|
ENV['PWD'] = project_fixture_path
|
31
34
|
end
|
32
35
|
|
33
36
|
context "config" do
|
34
37
|
before do
|
35
|
-
|
38
|
+
capistrano_config.dry_run = true
|
36
39
|
end
|
37
40
|
|
38
41
|
it "should be instantiated with the right params" do
|
@@ -46,7 +49,7 @@ if capistrano2_present?
|
|
46
49
|
|
47
50
|
context "when appsignal_config is available" do
|
48
51
|
before do
|
49
|
-
|
52
|
+
capistrano_config.set(:appsignal_config, :name => 'AppName')
|
50
53
|
end
|
51
54
|
|
52
55
|
it "should be instantiated with the right params" do
|
@@ -60,8 +63,8 @@ if capistrano2_present?
|
|
60
63
|
|
61
64
|
context "when rack_env is used instead of rails_env" do
|
62
65
|
before do
|
63
|
-
|
64
|
-
|
66
|
+
capistrano_config.unset(:rails_env)
|
67
|
+
capistrano_config.set(:rack_env, 'rack_production')
|
65
68
|
end
|
66
69
|
|
67
70
|
it "should be instantiated with the right params" do
|
@@ -76,8 +79,8 @@ if capistrano2_present?
|
|
76
79
|
|
77
80
|
context "when stage is used instead of rack_env / rails_env" do
|
78
81
|
before do
|
79
|
-
|
80
|
-
|
82
|
+
capistrano_config.unset(:rails_env)
|
83
|
+
capistrano_config.set(:stage, 'stage_production')
|
81
84
|
end
|
82
85
|
|
83
86
|
it "should be instantiated with the right params" do
|
@@ -92,9 +95,9 @@ if capistrano2_present?
|
|
92
95
|
|
93
96
|
context "when appsignal_env is set" do
|
94
97
|
before do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
+
capistrano_config.set(:rack_env, 'rack_production')
|
99
|
+
capistrano_config.set(:stage, 'stage_production')
|
100
|
+
capistrano_config.set(:appsignal_env, 'appsignal_production')
|
98
101
|
end
|
99
102
|
|
100
103
|
it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
|
@@ -109,14 +112,15 @@ if capistrano2_present?
|
|
109
112
|
end
|
110
113
|
|
111
114
|
after do
|
112
|
-
|
113
|
-
@capistrano_config.unset(:stage)
|
114
|
-
@capistrano_config.unset(:rack_env)
|
115
|
-
@capistrano_config.unset(:appsignal_env)
|
115
|
+
capistrano_config.find_and_execute_task('appsignal:deploy')
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
describe "markers" do
|
120
|
+
def stub_marker_request(data = {})
|
121
|
+
stub_api_request config, 'markers', marker_data.merge(data)
|
122
|
+
end
|
123
|
+
|
120
124
|
let(:marker_data) do
|
121
125
|
{
|
122
126
|
:revision => '503ce0923ed177a3ce000005',
|
@@ -125,80 +129,66 @@ if capistrano2_present?
|
|
125
129
|
end
|
126
130
|
|
127
131
|
context "when active for this environment" do
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
)
|
133
|
-
|
132
|
+
it "transmits marker" do
|
133
|
+
stub_marker_request.to_return(:status => 200)
|
134
|
+
capistrano_config.find_and_execute_task('appsignal:deploy')
|
135
|
+
|
136
|
+
expect(out_stream.string).to include \
|
137
|
+
'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
|
138
|
+
'Appsignal has been notified of this deploy!'
|
134
139
|
end
|
135
140
|
|
136
|
-
context "
|
141
|
+
context "with overridden revision" do
|
137
142
|
before do
|
138
|
-
|
139
|
-
|
143
|
+
capistrano_config.set(:appsignal_revision, 'abc123')
|
144
|
+
stub_marker_request(:revision => 'abc123').to_return(:status => 200)
|
145
|
+
capistrano_config.find_and_execute_task('appsignal:deploy')
|
140
146
|
end
|
141
147
|
|
142
|
-
it "
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
).and_return(@marker)
|
147
|
-
|
148
|
-
@capistrano_config.find_and_execute_task('appsignal:deploy')
|
148
|
+
it "transmits the overriden revision" do
|
149
|
+
expect(out_stream.string).to include \
|
150
|
+
'Notifying Appsignal of deploy with: revision: abc123, user: batman',
|
151
|
+
'Appsignal has been notified of this deploy!'
|
149
152
|
end
|
153
|
+
end
|
150
154
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
out_stream.string.should include('Appsignal has been notified of this deploy!')
|
155
|
+
context "with failed request" do
|
156
|
+
before do
|
157
|
+
stub_marker_request.to_return(:status => 500)
|
158
|
+
capistrano_config.find_and_execute_task('appsignal:deploy')
|
156
159
|
end
|
157
160
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
{
|
165
|
-
:revision => 'abc123',
|
166
|
-
:user => 'batman'
|
167
|
-
},
|
168
|
-
kind_of(Appsignal::Config)
|
169
|
-
).and_return(@marker)
|
170
|
-
|
171
|
-
@capistrano_config.find_and_execute_task('appsignal:deploy')
|
172
|
-
end
|
161
|
+
it "does not transmit marker" do
|
162
|
+
output = out_stream.string
|
163
|
+
expect(output).to include \
|
164
|
+
'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
|
165
|
+
'Something went wrong while trying to notify Appsignal:'
|
166
|
+
expect(output).to_not include 'Appsignal has been notified of this deploy!'
|
173
167
|
end
|
174
168
|
end
|
175
169
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
context "dry run" do
|
183
|
-
before { @capistrano_config.dry_run = true }
|
170
|
+
context "when dry run" do
|
171
|
+
before do
|
172
|
+
capistrano_config.dry_run = true
|
173
|
+
capistrano_config.find_and_execute_task('appsignal:deploy')
|
174
|
+
end
|
184
175
|
|
185
|
-
it "
|
186
|
-
|
187
|
-
|
188
|
-
out_stream.string.should include('Dry run: AppSignal deploy marker not actually sent.')
|
176
|
+
it "does not transmit marker" do
|
177
|
+
expect(out_stream.string).to include \
|
178
|
+
'Dry run: AppSignal deploy marker not actually sent.'
|
189
179
|
end
|
190
180
|
end
|
191
181
|
end
|
192
182
|
|
193
183
|
context "when not active for this environment" do
|
194
184
|
before do
|
195
|
-
|
185
|
+
capistrano_config.set(:rails_env, 'nonsense')
|
186
|
+
capistrano_config.find_and_execute_task('appsignal:deploy')
|
196
187
|
end
|
197
188
|
|
198
|
-
it "
|
199
|
-
|
200
|
-
|
201
|
-
out_stream.string.should include('Not notifying of deploy, config is not active for environment: nonsense')
|
189
|
+
it "does not transmit marker" do
|
190
|
+
expect(out_stream.string).to include \
|
191
|
+
"Not notifying of deploy, config is not active for environment: nonsense"
|
202
192
|
end
|
203
193
|
end
|
204
194
|
end
|
@@ -9,11 +9,19 @@ if capistrano3_present?
|
|
9
9
|
let(:config) { project_fixture_config }
|
10
10
|
let(:out_stream) { StringIO.new }
|
11
11
|
let(:logger) { Logger.new(out_stream) }
|
12
|
-
|
12
|
+
let!(:capistrano_config) do
|
13
|
+
Capistrano::Configuration.reset!
|
14
|
+
Capistrano::Configuration.env.tap do |c|
|
15
|
+
c.set(:log_level, :error)
|
16
|
+
c.set(:logger, logger)
|
17
|
+
c.set(:rails_env, 'production')
|
18
|
+
c.set(:repository, 'master')
|
19
|
+
c.set(:deploy_to, '/home/username/app')
|
20
|
+
c.set(:current_release, '')
|
21
|
+
c.set(:current_revision, '503ce0923ed177a3ce000005')
|
22
|
+
end
|
23
|
+
end
|
13
24
|
before do
|
14
|
-
@capistrano_config = Capistrano::Configuration.env
|
15
|
-
@capistrano_config.set(:log_level, :error)
|
16
|
-
@capistrano_config.set(:logger, logger)
|
17
25
|
Rake::Task['appsignal:deploy'].reenable
|
18
26
|
end
|
19
27
|
around do |example|
|
@@ -26,11 +34,6 @@ if capistrano3_present?
|
|
26
34
|
|
27
35
|
describe "appsignal:deploy task" do
|
28
36
|
before do
|
29
|
-
@capistrano_config.set(:rails_env, 'production')
|
30
|
-
@capistrano_config.set(:repository, 'master')
|
31
|
-
@capistrano_config.set(:deploy_to, '/home/username/app')
|
32
|
-
@capistrano_config.set(:current_release, '')
|
33
|
-
@capistrano_config.set(:current_revision, '503ce0923ed177a3ce000005')
|
34
37
|
ENV['USER'] = 'batman'
|
35
38
|
ENV['PWD'] = project_fixture_path
|
36
39
|
end
|
@@ -47,7 +50,7 @@ if capistrano3_present?
|
|
47
50
|
|
48
51
|
context "when appsignal_config is available" do
|
49
52
|
before do
|
50
|
-
|
53
|
+
capistrano_config.set(:appsignal_config, :name => 'AppName')
|
51
54
|
end
|
52
55
|
|
53
56
|
it "should be instantiated with the right params" do
|
@@ -61,8 +64,8 @@ if capistrano3_present?
|
|
61
64
|
|
62
65
|
context "when rack_env is the only env set" do
|
63
66
|
before do
|
64
|
-
|
65
|
-
|
67
|
+
capistrano_config.delete(:rails_env)
|
68
|
+
capistrano_config.set(:rack_env, 'rack_production')
|
66
69
|
end
|
67
70
|
|
68
71
|
it "should be instantiated with the rack env" do
|
@@ -77,8 +80,8 @@ if capistrano3_present?
|
|
77
80
|
|
78
81
|
context "when stage is set" do
|
79
82
|
before do
|
80
|
-
|
81
|
-
|
83
|
+
capistrano_config.set(:rack_env, 'rack_production')
|
84
|
+
capistrano_config.set(:stage, 'stage_production')
|
82
85
|
end
|
83
86
|
|
84
87
|
it "should prefer the stage rather than rails_env and rack_env" do
|
@@ -93,9 +96,9 @@ if capistrano3_present?
|
|
93
96
|
|
94
97
|
context "when appsignal_env is set" do
|
95
98
|
before do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
+
capistrano_config.set(:rack_env, 'rack_production')
|
100
|
+
capistrano_config.set(:stage, 'stage_production')
|
101
|
+
capistrano_config.set(:appsignal_env, 'appsignal_production')
|
99
102
|
end
|
100
103
|
|
101
104
|
it "should prefer the appsignal_env rather than stage, rails_env and rack_env" do
|
@@ -111,13 +114,14 @@ if capistrano3_present?
|
|
111
114
|
|
112
115
|
after do
|
113
116
|
invoke('appsignal:deploy')
|
114
|
-
@capistrano_config.delete(:stage)
|
115
|
-
@capistrano_config.delete(:rack_env)
|
116
|
-
@capistrano_config.delete(:appsignal_env)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
|
-
|
120
|
+
describe "markers" do
|
121
|
+
def stub_marker_request(data = {})
|
122
|
+
stub_api_request config, 'markers', marker_data.merge(data)
|
123
|
+
end
|
124
|
+
|
121
125
|
let(:marker_data) do
|
122
126
|
{
|
123
127
|
:revision => '503ce0923ed177a3ce000005',
|
@@ -126,70 +130,54 @@ if capistrano3_present?
|
|
126
130
|
end
|
127
131
|
|
128
132
|
context "when active for this environment" do
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
)
|
134
|
-
|
133
|
+
it "transmits marker" do
|
134
|
+
stub_marker_request.to_return(:status => 200)
|
135
|
+
invoke('appsignal:deploy')
|
136
|
+
|
137
|
+
expect(out_stream.string).to include \
|
138
|
+
'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
|
139
|
+
'Appsignal has been notified of this deploy!'
|
135
140
|
end
|
136
141
|
|
137
|
-
context "
|
142
|
+
context "with overridden revision" do
|
138
143
|
before do
|
139
|
-
|
140
|
-
|
144
|
+
capistrano_config.set(:appsignal_revision, 'abc123')
|
145
|
+
stub_marker_request(:revision => 'abc123').to_return(:status => 200)
|
146
|
+
invoke('appsignal:deploy')
|
141
147
|
end
|
142
148
|
|
143
|
-
it "
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
).and_return(@marker)
|
148
|
-
|
149
|
-
invoke('appsignal:deploy')
|
149
|
+
it "transmits the overriden revision" do
|
150
|
+
expect(out_stream.string).to include \
|
151
|
+
'Notifying Appsignal of deploy with: revision: abc123, user: batman',
|
152
|
+
'Appsignal has been notified of this deploy!'
|
150
153
|
end
|
154
|
+
end
|
151
155
|
|
152
|
-
|
153
|
-
|
156
|
+
context "with failed request" do
|
157
|
+
before do
|
158
|
+
stub_marker_request.to_return(:status => 500)
|
154
159
|
invoke('appsignal:deploy')
|
155
|
-
out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
|
156
|
-
out_stream.string.should include('ppsignal has been notified of this deploy!')
|
157
160
|
end
|
158
161
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
{
|
166
|
-
:revision => 'abc123',
|
167
|
-
:user => 'batman'
|
168
|
-
},
|
169
|
-
kind_of(Appsignal::Config)
|
170
|
-
).and_return(@marker)
|
171
|
-
|
172
|
-
invoke('appsignal:deploy')
|
173
|
-
end
|
162
|
+
it "does not transmit marker" do
|
163
|
+
output = out_stream.string
|
164
|
+
expect(output).to include \
|
165
|
+
'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
|
166
|
+
'Something went wrong while trying to notify Appsignal:'
|
167
|
+
expect(output).to_not include 'Appsignal has been notified of this deploy!'
|
174
168
|
end
|
175
169
|
end
|
176
|
-
|
177
|
-
it "should not transmit data" do
|
178
|
-
invoke('appsignal:deploy')
|
179
|
-
out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
|
180
|
-
out_stream.string.should include('Something went wrong while trying to notify Appsignal:')
|
181
|
-
end
|
182
170
|
end
|
183
171
|
|
184
172
|
context "when not active for this environment" do
|
185
173
|
before do
|
186
|
-
|
174
|
+
capistrano_config.set(:rails_env, 'nonsense')
|
175
|
+
invoke('appsignal:deploy')
|
187
176
|
end
|
188
177
|
|
189
178
|
it "should not send deploy marker" do
|
190
|
-
|
191
|
-
|
192
|
-
out_stream.string.should include("Not notifying of deploy, config is not active for environment: nonsense")
|
179
|
+
expect(out_stream.string).to include \
|
180
|
+
"Not notifying of deploy, config is not active for environment: nonsense"
|
193
181
|
end
|
194
182
|
end
|
195
183
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe Appsignal::Marker do
|
2
2
|
let(:config) { project_fixture_config }
|
3
|
-
let(:marker)
|
4
|
-
|
3
|
+
let(:marker) do
|
4
|
+
described_class.new(
|
5
5
|
{
|
6
6
|
:revision => '503ce0923ed177a3ce000005',
|
7
7
|
:repository => 'master',
|
@@ -10,53 +10,46 @@ describe Appsignal::Marker do
|
|
10
10
|
},
|
11
11
|
config
|
12
12
|
)
|
13
|
-
|
13
|
+
end
|
14
14
|
let(:out_stream) { StringIO.new }
|
15
15
|
around do |example|
|
16
16
|
capture_stdout(out_stream) { example.run }
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Appsignal::Transmitter.should_receive(:new).with(
|
23
|
-
'markers', config
|
24
|
-
).and_return(transmitter)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should transmit data" do
|
28
|
-
transmitter.should_receive(:transmit).with(
|
29
|
-
:revision => '503ce0923ed177a3ce000005',
|
30
|
-
:repository => 'master',
|
31
|
-
:user => 'batman',
|
32
|
-
:rails_env => 'production'
|
33
|
-
)
|
34
|
-
|
35
|
-
marker.transmit
|
19
|
+
describe "#transmit" do
|
20
|
+
def stub_marker_request
|
21
|
+
stub_api_request config, "markers", marker.marker_data
|
36
22
|
end
|
37
23
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
24
|
+
context "when request is valid" do
|
25
|
+
before do
|
26
|
+
stub_marker_request.to_return(:status => 200)
|
27
|
+
marker.transmit
|
28
|
+
end
|
29
|
+
|
30
|
+
it "outputs success" do
|
31
|
+
output = out_stream.string
|
32
|
+
expect(output).to include \
|
33
|
+
'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
|
34
|
+
'Appsignal has been notified of this deploy!'
|
35
|
+
end
|
45
36
|
end
|
46
37
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
38
|
+
context "when request is invalid" do
|
39
|
+
before do
|
40
|
+
stub_marker_request.to_return(:status => 500)
|
41
|
+
marker.transmit
|
42
|
+
end
|
43
|
+
|
44
|
+
it "outputs failure" do
|
45
|
+
output = out_stream.string
|
46
|
+
expect(output).to include \
|
47
|
+
'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
|
48
|
+
"Something went wrong while trying to notify Appsignal: 500 at "\
|
49
|
+
"#{config[:endpoint]}/1/markers"
|
50
|
+
expect(output).to_not include \
|
51
|
+
'Appsignal has been notified of this deploy!'
|
52
|
+
end
|
60
53
|
end
|
61
54
|
end
|
62
55
|
end
|
@@ -27,7 +27,7 @@ describe Appsignal::Transmitter do
|
|
27
27
|
"&environment=production&gem_version=#{Appsignal::VERSION}"\
|
28
28
|
"&hostname=#{config.config_hash[:hostname]}&name=TestApp"
|
29
29
|
).with(
|
30
|
-
:body =>
|
30
|
+
:body => Appsignal::Utils::Gzip.compress("{\"the\":\"payload\"}"),
|
31
31
|
:headers => {
|
32
32
|
'Content-Encoding' => 'gzip',
|
33
33
|
'Content-Type' => 'application/json; charset=UTF-8',
|
@@ -84,13 +84,9 @@ describe Appsignal::Transmitter do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
describe "#http_post" do
|
87
|
-
before do
|
88
|
-
Socket.stub(:gethostname => 'app1.local')
|
89
|
-
end
|
90
|
-
|
91
87
|
subject { instance.send(:http_post, 'the' => 'payload') }
|
92
88
|
|
93
|
-
its(:body) { should eq
|
89
|
+
its(:body) { should eq Appsignal::Utils::Gzip.compress("{\"the\":\"payload\"}") }
|
94
90
|
its(:path) { should eq instance.uri.request_uri }
|
95
91
|
|
96
92
|
it "should have the correct headers" do
|
@@ -0,0 +1,10 @@
|
|
1
|
+
describe Appsignal::Utils::Gzip do
|
2
|
+
describe ".compress" do
|
3
|
+
let(:value) { "foo" }
|
4
|
+
subject { described_class.compress(value).force_encoding("UTF-8") }
|
5
|
+
|
6
|
+
it "returns a gziped value" do
|
7
|
+
expect(subject).to eq("x\u0001K\xCB\xCF\a\u0000\u0002\x82\u0001E")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module ApiRequestHelper
|
2
|
+
def stub_api_request(config, path, body)
|
3
|
+
body = Appsignal::Utils::Gzip.compress(Appsignal::Utils::JSON.generate(body))
|
4
|
+
stub_request(:post, "#{config[:endpoint]}/1/#{path}").with(
|
5
|
+
:body => body,
|
6
|
+
:query => {
|
7
|
+
:api_key => config[:push_api_key],
|
8
|
+
:name => config[:name],
|
9
|
+
:environment => config.env,
|
10
|
+
:hostname => config[:hostname],
|
11
|
+
:gem_version => Appsignal::VERSION
|
12
|
+
},
|
13
|
+
:headers => {
|
14
|
+
'Content-Encoding' => 'gzip',
|
15
|
+
'Content-Type' => 'application/json; charset=UTF-8',
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
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: 1.3.6
|
4
|
+
version: 1.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Beekman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-09-
|
12
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- spec/lib/appsignal/transaction_spec.rb
|
273
273
|
- spec/lib/appsignal/transmitter_spec.rb
|
274
274
|
- spec/lib/appsignal/update_active_support_spec.rb
|
275
|
+
- spec/lib/appsignal/utils/gzip_spec.rb
|
275
276
|
- spec/lib/appsignal/utils/params_sanitizer_spec.rb
|
276
277
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
277
278
|
- spec/lib/appsignal/utils_spec.rb
|
@@ -281,6 +282,7 @@ files:
|
|
281
282
|
- spec/support/delegate_matcher.rb
|
282
283
|
- spec/support/fixtures/generated_config.yml
|
283
284
|
- spec/support/fixtures/uploaded_file.txt
|
285
|
+
- spec/support/helpers/api_request_helper.rb
|
284
286
|
- spec/support/helpers/config_helpers.rb
|
285
287
|
- spec/support/helpers/directory_helper.rb
|
286
288
|
- spec/support/helpers/env_helpers.rb
|
@@ -314,9 +316,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
314
316
|
version: '1.9'
|
315
317
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
316
318
|
requirements:
|
317
|
-
- - "
|
319
|
+
- - ">="
|
318
320
|
- !ruby/object:Gem::Version
|
319
|
-
version:
|
321
|
+
version: '0'
|
320
322
|
requirements: []
|
321
323
|
rubyforge_project:
|
322
324
|
rubygems_version: 2.4.5
|
@@ -378,6 +380,7 @@ test_files:
|
|
378
380
|
- spec/lib/appsignal/transaction_spec.rb
|
379
381
|
- spec/lib/appsignal/transmitter_spec.rb
|
380
382
|
- spec/lib/appsignal/update_active_support_spec.rb
|
383
|
+
- spec/lib/appsignal/utils/gzip_spec.rb
|
381
384
|
- spec/lib/appsignal/utils/params_sanitizer_spec.rb
|
382
385
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
383
386
|
- spec/lib/appsignal/utils_spec.rb
|
@@ -387,6 +390,7 @@ test_files:
|
|
387
390
|
- spec/support/delegate_matcher.rb
|
388
391
|
- spec/support/fixtures/generated_config.yml
|
389
392
|
- spec/support/fixtures/uploaded_file.txt
|
393
|
+
- spec/support/helpers/api_request_helper.rb
|
390
394
|
- spec/support/helpers/config_helpers.rb
|
391
395
|
- spec/support/helpers/directory_helper.rb
|
392
396
|
- spec/support/helpers/env_helpers.rb
|