appsignal 0.11.9 → 0.11.10.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -0
- data/lib/appsignal/transaction.rb +18 -4
- data/lib/appsignal/transaction/formatter.rb +1 -14
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal/zipped_payload.rb +25 -1
- data/spec/lib/appsignal/transaction/formatter_spec.rb +3 -12
- data/spec/lib/appsignal/transaction_spec.rb +58 -4
- data/spec/lib/appsignal/zipped_payload_spec.rb +25 -1
- metadata +25 -41
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6a30600b4b012173c320662d41ae079891c0cfc2
|
4
|
+
data.tar.gz: bd7eb17b8bea68b32f91b6a7d7eb0b6e23fa6208
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b84d295eecb0fa909d4831c4009564592deebc7f9cd25cbbd41526e288ff1502bc880d69a8aff38fa175e5bb8ae937b255d558e5a69a7f6446b50b2ca5b93d9
|
7
|
+
data.tar.gz: 3643403fb62be693d355a31d93fdc574a83a6d84154aaefc9cb0a8ca878f7defb0b8e191ea9f59f6074df3fc59ffb9749e969eceeb988c0c68a1142ca038f250
|
data/CHANGELOG.md
CHANGED
@@ -38,7 +38,7 @@ module Appsignal
|
|
38
38
|
@request_id = request_id
|
39
39
|
@events = []
|
40
40
|
@process_action_event = nil
|
41
|
-
@exception =
|
41
|
+
@exception = {}
|
42
42
|
@env = env
|
43
43
|
@tags = {}
|
44
44
|
@paused = false
|
@@ -92,13 +92,27 @@ module Appsignal
|
|
92
92
|
@events << event unless @paused == true
|
93
93
|
end
|
94
94
|
|
95
|
-
def add_exception(ex)
|
95
|
+
def add_exception(ex=nil)
|
96
|
+
return unless ex
|
96
97
|
@time = Time.now.utc.to_f
|
97
|
-
@exception =
|
98
|
+
@exception = {
|
99
|
+
:exception => ex.class.name,
|
100
|
+
:message => ex.message,
|
101
|
+
:backtrace => clean_backtrace(ex)
|
102
|
+
}
|
98
103
|
end
|
99
104
|
|
100
105
|
def exception?
|
101
|
-
|
106
|
+
exception.any?
|
107
|
+
end
|
108
|
+
|
109
|
+
def clean_backtrace(exception)
|
110
|
+
return [] unless exception.backtrace.is_a?(Array)
|
111
|
+
if defined?(::Rails)
|
112
|
+
::Rails.backtrace_cleaner.clean(exception.backtrace, nil)
|
113
|
+
else
|
114
|
+
exception.backtrace
|
115
|
+
end
|
102
116
|
end
|
103
117
|
|
104
118
|
def slow_request?
|
@@ -60,20 +60,7 @@ module Appsignal
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def add_exception_to_hash!
|
63
|
-
hash[:exception] =
|
64
|
-
:exception => exception.class.name,
|
65
|
-
:message => exception.message,
|
66
|
-
:backtrace => clean_backtrace(exception)
|
67
|
-
}
|
68
|
-
end
|
69
|
-
|
70
|
-
def clean_backtrace(exception)
|
71
|
-
return [] unless exception.backtrace.is_a?(Array)
|
72
|
-
if defined?(::Rails)
|
73
|
-
::Rails.backtrace_cleaner.clean(exception.backtrace, nil)
|
74
|
-
else
|
75
|
-
exception.backtrace
|
76
|
-
end
|
63
|
+
hash[:exception] = exception
|
77
64
|
end
|
78
65
|
|
79
66
|
def add_events_to_hash!
|
data/lib/appsignal/version.rb
CHANGED
@@ -4,10 +4,34 @@ module Appsignal
|
|
4
4
|
|
5
5
|
def initialize(given_body)
|
6
6
|
@body = Zlib::Deflate.deflate(
|
7
|
-
|
7
|
+
Appsignal::ZippedPayload.json_generate(given_body),
|
8
8
|
Zlib::BEST_SPEED
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
12
|
+
protected
|
13
|
+
|
14
|
+
def self.json_generate(given_body)
|
15
|
+
JSON.generate(jsonify(given_body))
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.jsonify(value)
|
19
|
+
case value
|
20
|
+
when String
|
21
|
+
begin
|
22
|
+
value.encode('utf-8')
|
23
|
+
rescue Encoding::UndefinedConversionError
|
24
|
+
'[invalid-utf8]'
|
25
|
+
end
|
26
|
+
when Numeric, NilClass, TrueClass, FalseClass
|
27
|
+
value
|
28
|
+
when Hash
|
29
|
+
Hash[value.map { |k, v| [jsonify(k), jsonify(v)] }]
|
30
|
+
when Array
|
31
|
+
value.map { |v| jsonify(v) }
|
32
|
+
else
|
33
|
+
jsonify value.to_s
|
34
|
+
end
|
35
|
+
end
|
12
36
|
end
|
13
37
|
end
|
@@ -83,21 +83,12 @@ describe Appsignal::Transaction::Formatter do
|
|
83
83
|
context "exception content" do
|
84
84
|
subject { formatter.to_hash[:exception] }
|
85
85
|
|
86
|
+
it "should set the exception" do
|
87
|
+
subject.should eql(transaction_with_exception.exception)
|
88
|
+
end
|
86
89
|
its(:keys) { should =~ [:exception, :message, :backtrace] }
|
87
90
|
its([:exception]) { should == 'ArgumentError' }
|
88
91
|
its([:message]) { should == 'oh no' }
|
89
|
-
|
90
|
-
if rails_present?
|
91
|
-
its([:backtrace]) { should == [
|
92
|
-
'app/controllers/somethings_controller.rb:10',
|
93
|
-
'/user/local/ruby/path.rb:8'
|
94
|
-
] }
|
95
|
-
else
|
96
|
-
its([:backtrace]) { should == [
|
97
|
-
File.join(project_fixture_path, 'app/controllers/somethings_controller.rb:10'),
|
98
|
-
'/user/local/ruby/path.rb:8'
|
99
|
-
] }
|
100
|
-
end
|
101
92
|
end
|
102
93
|
end
|
103
94
|
|
@@ -190,13 +190,56 @@ describe Appsignal::Transaction do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
context "using exceptions" do
|
193
|
-
let(:exception)
|
193
|
+
let(:exception) do
|
194
|
+
double(
|
195
|
+
:exception,
|
196
|
+
:class => double(:name => 'test'),
|
197
|
+
:message => 'Broken',
|
198
|
+
:backtrace => [
|
199
|
+
File.join(project_fixture_path, 'app/controllers/somethings_controller.rb:10').to_s,
|
200
|
+
'/user/local/ruby/path.rb:8'
|
201
|
+
]
|
202
|
+
)
|
203
|
+
end
|
194
204
|
|
195
205
|
describe '#add_exception' do
|
196
|
-
it 'should add an exception' do
|
206
|
+
it 'should add an exception', :if => rails_present? do
|
207
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new('4.2.1')
|
208
|
+
expect {
|
209
|
+
transaction.add_exception(exception)
|
210
|
+
}.to change(transaction, :exception).to({
|
211
|
+
:exception => 'test',
|
212
|
+
:message => 'Broken',
|
213
|
+
:backtrace => [
|
214
|
+
'spec/support/project_fixture/app/controllers/somethings_controller.rb:10',
|
215
|
+
'/user/local/ruby/path.rb:8'
|
216
|
+
]
|
217
|
+
})
|
218
|
+
else
|
219
|
+
expect {
|
220
|
+
transaction.add_exception(exception)
|
221
|
+
}.to change(transaction, :exception).to({
|
222
|
+
:exception => 'test',
|
223
|
+
:message => 'Broken',
|
224
|
+
:backtrace => [
|
225
|
+
'app/controllers/somethings_controller.rb:10',
|
226
|
+
'/user/local/ruby/path.rb:8'
|
227
|
+
]
|
228
|
+
})
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
it 'should add an exception', :if => !rails_present? do
|
197
233
|
expect {
|
198
234
|
transaction.add_exception(exception)
|
199
|
-
}.to change(transaction, :exception).to(
|
235
|
+
}.to change(transaction, :exception).to({
|
236
|
+
:exception => 'test',
|
237
|
+
:message => 'Broken',
|
238
|
+
:backtrace => [
|
239
|
+
File.join(project_fixture_path, 'app/controllers/somethings_controller.rb:10'),
|
240
|
+
'/user/local/ruby/path.rb:8'
|
241
|
+
]
|
242
|
+
})
|
200
243
|
end
|
201
244
|
end
|
202
245
|
|
@@ -397,6 +440,17 @@ describe Appsignal::Transaction do
|
|
397
440
|
|
398
441
|
describe '#complete!' do
|
399
442
|
let(:event) { double(:event) }
|
443
|
+
let(:exception) do
|
444
|
+
double(
|
445
|
+
:exception,
|
446
|
+
:class => double(:name => 'test'),
|
447
|
+
:message => 'Broken',
|
448
|
+
:backtrace => [
|
449
|
+
'app/controllers/somethings_controller.rb:10',
|
450
|
+
'/user/local/ruby/path.rb:8'
|
451
|
+
]
|
452
|
+
)
|
453
|
+
end
|
400
454
|
before do
|
401
455
|
Appsignal::IPC.stub(:current => nil)
|
402
456
|
transaction.set_process_action_event(notification_event)
|
@@ -427,7 +481,7 @@ describe Appsignal::Transaction do
|
|
427
481
|
end
|
428
482
|
|
429
483
|
context 'with exception' do
|
430
|
-
before { transaction.add_exception(
|
484
|
+
before { transaction.add_exception(exception) }
|
431
485
|
|
432
486
|
it 'should add transaction to the agent' do
|
433
487
|
Appsignal.should_receive(:enqueue).with(transaction)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Appsignal::ZippedPayload do
|
4
|
-
|
5
4
|
describe "#initialize" do
|
6
5
|
it "should initialize a new `Appsignal::ZippedPayload` and zip the body" do
|
7
6
|
payload = Appsignal::ZippedPayload.new({'the' => 'payload'})
|
@@ -13,4 +12,29 @@ describe Appsignal::ZippedPayload do
|
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
15
|
+
describe ".json_generate" do
|
16
|
+
subject { Appsignal::ZippedPayload.send(:json_generate, body) }
|
17
|
+
|
18
|
+
context "with a valid body" do
|
19
|
+
let(:body) { {'the' => 'payload'} }
|
20
|
+
|
21
|
+
it { should == "{\"the\":\"payload\"}" }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with a body that contains strings with invalid utf-8 content" do
|
25
|
+
let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack('c*') }
|
26
|
+
let(:body) { {
|
27
|
+
'field_one' => [0x61, 0x61].pack('c*'),
|
28
|
+
'field_two' => string_with_invalid_utf8,
|
29
|
+
'field_three' => [
|
30
|
+
'one', string_with_invalid_utf8
|
31
|
+
],
|
32
|
+
'field_four' => {
|
33
|
+
'one' => string_with_invalid_utf8
|
34
|
+
}
|
35
|
+
} }
|
36
|
+
|
37
|
+
it { should == "{\"field_one\":\"aa\",\"field_two\":\"[invalid-utf8]\",\"field_three\":[\"one\",\"[invalid-utf8]\"],\"field_four\":{\"one\":\"[invalid-utf8]\"}}" }
|
38
|
+
end
|
39
|
+
end
|
16
40
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
5
|
-
prerelease:
|
4
|
+
version: 0.11.10.beta.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Robert Beekman
|
@@ -13,118 +12,104 @@ authors:
|
|
13
12
|
autorequire:
|
14
13
|
bindir: bin
|
15
14
|
cert_chain: []
|
16
|
-
date: 2015-
|
15
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
17
16
|
dependencies:
|
18
17
|
- !ruby/object:Gem::Dependency
|
19
18
|
name: rack
|
20
19
|
requirement: !ruby/object:Gem::Requirement
|
21
|
-
none: false
|
22
20
|
requirements:
|
23
|
-
- -
|
21
|
+
- - ">="
|
24
22
|
- !ruby/object:Gem::Version
|
25
23
|
version: '0'
|
26
24
|
type: :runtime
|
27
25
|
prerelease: false
|
28
26
|
version_requirements: !ruby/object:Gem::Requirement
|
29
|
-
none: false
|
30
27
|
requirements:
|
31
|
-
- -
|
28
|
+
- - ">="
|
32
29
|
- !ruby/object:Gem::Version
|
33
30
|
version: '0'
|
34
31
|
- !ruby/object:Gem::Dependency
|
35
32
|
name: thread_safe
|
36
33
|
requirement: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
34
|
requirements:
|
39
|
-
- -
|
35
|
+
- - ">="
|
40
36
|
- !ruby/object:Gem::Version
|
41
37
|
version: '0'
|
42
38
|
type: :runtime
|
43
39
|
prerelease: false
|
44
40
|
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
41
|
requirements:
|
47
|
-
- -
|
42
|
+
- - ">="
|
48
43
|
- !ruby/object:Gem::Version
|
49
44
|
version: '0'
|
50
45
|
- !ruby/object:Gem::Dependency
|
51
46
|
name: rake
|
52
47
|
requirement: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
48
|
requirements:
|
55
|
-
- -
|
49
|
+
- - ">="
|
56
50
|
- !ruby/object:Gem::Version
|
57
51
|
version: '0'
|
58
52
|
type: :development
|
59
53
|
prerelease: false
|
60
54
|
version_requirements: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
55
|
requirements:
|
63
|
-
- -
|
56
|
+
- - ">="
|
64
57
|
- !ruby/object:Gem::Version
|
65
58
|
version: '0'
|
66
59
|
- !ruby/object:Gem::Dependency
|
67
60
|
name: rspec
|
68
61
|
requirement: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
62
|
requirements:
|
71
|
-
- - ~>
|
63
|
+
- - "~>"
|
72
64
|
- !ruby/object:Gem::Version
|
73
65
|
version: 2.14.1
|
74
66
|
type: :development
|
75
67
|
prerelease: false
|
76
68
|
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
69
|
requirements:
|
79
|
-
- - ~>
|
70
|
+
- - "~>"
|
80
71
|
- !ruby/object:Gem::Version
|
81
72
|
version: 2.14.1
|
82
73
|
- !ruby/object:Gem::Dependency
|
83
74
|
name: pry
|
84
75
|
requirement: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
76
|
requirements:
|
87
|
-
- -
|
77
|
+
- - ">="
|
88
78
|
- !ruby/object:Gem::Version
|
89
79
|
version: '0'
|
90
80
|
type: :development
|
91
81
|
prerelease: false
|
92
82
|
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
83
|
requirements:
|
95
|
-
- -
|
84
|
+
- - ">="
|
96
85
|
- !ruby/object:Gem::Version
|
97
86
|
version: '0'
|
98
87
|
- !ruby/object:Gem::Dependency
|
99
88
|
name: timecop
|
100
89
|
requirement: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
90
|
requirements:
|
103
|
-
- -
|
91
|
+
- - ">="
|
104
92
|
- !ruby/object:Gem::Version
|
105
93
|
version: '0'
|
106
94
|
type: :development
|
107
95
|
prerelease: false
|
108
96
|
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
97
|
requirements:
|
111
|
-
- -
|
98
|
+
- - ">="
|
112
99
|
- !ruby/object:Gem::Version
|
113
100
|
version: '0'
|
114
101
|
- !ruby/object:Gem::Dependency
|
115
102
|
name: webmock
|
116
103
|
requirement: !ruby/object:Gem::Requirement
|
117
|
-
none: false
|
118
104
|
requirements:
|
119
|
-
- -
|
105
|
+
- - ">="
|
120
106
|
- !ruby/object:Gem::Version
|
121
107
|
version: '0'
|
122
108
|
type: :development
|
123
109
|
prerelease: false
|
124
110
|
version_requirements: !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
111
|
requirements:
|
127
|
-
- -
|
112
|
+
- - ">="
|
128
113
|
- !ruby/object:Gem::Version
|
129
114
|
version: '0'
|
130
115
|
description: The official appsignal.com gem
|
@@ -135,9 +120,9 @@ executables:
|
|
135
120
|
extensions: []
|
136
121
|
extra_rdoc_files: []
|
137
122
|
files:
|
138
|
-
- .gitignore
|
139
|
-
- .rspec
|
140
|
-
- .travis.yml
|
123
|
+
- ".gitignore"
|
124
|
+
- ".rspec"
|
125
|
+
- ".travis.yml"
|
141
126
|
- CHANGELOG.md
|
142
127
|
- Gemfile
|
143
128
|
- LICENSE
|
@@ -259,27 +244,26 @@ files:
|
|
259
244
|
homepage: https://github.com/appsignal/appsignal
|
260
245
|
licenses:
|
261
246
|
- MIT
|
247
|
+
metadata: {}
|
262
248
|
post_install_message:
|
263
249
|
rdoc_options: []
|
264
250
|
require_paths:
|
265
251
|
- lib
|
266
252
|
required_ruby_version: !ruby/object:Gem::Requirement
|
267
|
-
none: false
|
268
253
|
requirements:
|
269
|
-
- -
|
254
|
+
- - ">="
|
270
255
|
- !ruby/object:Gem::Version
|
271
256
|
version: '1.9'
|
272
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
273
|
-
none: false
|
274
258
|
requirements:
|
275
|
-
- -
|
259
|
+
- - ">"
|
276
260
|
- !ruby/object:Gem::Version
|
277
|
-
version:
|
261
|
+
version: 1.3.1
|
278
262
|
requirements: []
|
279
263
|
rubyforge_project:
|
280
|
-
rubygems_version:
|
264
|
+
rubygems_version: 2.4.5
|
281
265
|
signing_key:
|
282
|
-
specification_version:
|
266
|
+
specification_version: 4
|
283
267
|
summary: Logs performance and exception data from your app to appsignal.com
|
284
268
|
test_files:
|
285
269
|
- spec/lib/appsignal/agent_spec.rb
|