appsignal 1.1.0.beta.6 → 1.1.0.beta.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/ext/agent.yml +7 -7
- data/ext/appsignal_extension.c +7 -5
- data/ext/extconf.rb +9 -2
- data/lib/appsignal/config.rb +5 -2
- data/lib/appsignal/event_formatter.rb +2 -0
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -47
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +88 -0
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +6 -7
- data/lib/appsignal/event_formatter/sequel/sql_formatter.rb +13 -0
- data/lib/appsignal/hooks/sequel.rb +4 -7
- data/lib/appsignal/integrations/capistrano/appsignal.cap +1 -1
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +9 -5
- data/lib/appsignal/js_exception_transaction.rb +2 -2
- data/lib/appsignal/subscriber.rb +3 -2
- data/lib/appsignal/transaction.rb +8 -2
- data/lib/appsignal/transmitter.rb +1 -1
- data/lib/appsignal/utils.rb +38 -4
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/capistrano3_spec.rb +21 -1
- data/spec/lib/appsignal/config_spec.rb +12 -0
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +1 -1
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +14 -186
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +115 -0
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb +22 -0
- data/spec/lib/appsignal/extension_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/sequel_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +8 -5
- data/spec/lib/appsignal/subscriber_spec.rb +23 -5
- data/spec/lib/appsignal/transaction_spec.rb +21 -0
- data/spec/lib/appsignal/utils_spec.rb +48 -0
- data/spec/support/helpers/env_helpers.rb +1 -0
- metadata +8 -2
@@ -22,12 +22,12 @@ describe Appsignal::EventFormatter::Moped::QueryFormatter do
|
|
22
22
|
let(:op) do
|
23
23
|
double(
|
24
24
|
:full_collection_name => 'database.collection',
|
25
|
-
:selector => {'_id' => 'abc'},
|
25
|
+
:selector => {'query' => {'_id' => 'abc'}},
|
26
26
|
:class => double(:to_s => 'Moped::Protocol::Command')
|
27
27
|
)
|
28
28
|
end
|
29
29
|
|
30
|
-
it { should == ['Command', '{:database=>"database.collection", :selector=>{"
|
30
|
+
it { should == ['Command', '{:database=>"database.collection", :selector=>{"query"=>"?"}}'] }
|
31
31
|
end
|
32
32
|
|
33
33
|
context "Moped::Protocol::Query" do
|
@@ -80,13 +80,13 @@ describe Appsignal::EventFormatter::Moped::QueryFormatter do
|
|
80
80
|
double(
|
81
81
|
:full_collection_name => 'database.collection',
|
82
82
|
:selector => {'_id' => 'abc'},
|
83
|
-
:update => {'name' => 'James Bond'},
|
83
|
+
:update => {'user.name' => 'James Bond'},
|
84
84
|
:flags => [],
|
85
85
|
:class => double(:to_s => 'Moped::Protocol::Update')
|
86
86
|
)
|
87
87
|
end
|
88
88
|
|
89
|
-
it { should == ['Update', '{:database=>"database.collection", :selector=>{"_id"=>"?"}, :update=>{"
|
89
|
+
it { should == ['Update', '{:database=>"database.collection", :selector=>{"_id"=>"?"}, :update=>{"user.?"=>"?"}, :flags=>[]}'] }
|
90
90
|
end
|
91
91
|
|
92
92
|
context "Moped::Protocol::KillCursors" do
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Appsignal::EventFormatter::Sequel::SqlFormatter do
|
4
|
+
let(:klass) { Appsignal::EventFormatter::Sequel::SqlFormatter }
|
5
|
+
let(:formatter) { klass.new }
|
6
|
+
|
7
|
+
it "should register sql.sequel" do
|
8
|
+
Appsignal::EventFormatter.registered?('sql.sequel', klass).should be_true
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#format" do
|
12
|
+
let(:payload) do
|
13
|
+
{
|
14
|
+
sql: 'SELECT * FROM users'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { formatter.format(payload) }
|
19
|
+
|
20
|
+
it { should == [nil, 'SELECT * FROM users', 1] }
|
21
|
+
end
|
22
|
+
end
|
@@ -46,7 +46,7 @@ describe "extension loading and operation" do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should have a finish_event method" do
|
49
|
-
subject.finish_event(1, 'name', 'title', 'body')
|
49
|
+
subject.finish_event(1, 'name', 'title', 'body', 0)
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should have a set_transaction_error method" do
|
@@ -15,7 +15,7 @@ describe "Sequel integration", if: sequel_present? do
|
|
15
15
|
.at_least(:once)
|
16
16
|
expect( Appsignal::Extension ).to receive(:finish_event)
|
17
17
|
.at_least(:once)
|
18
|
-
.with(kind_of(Integer), "sql.sequel", "",
|
18
|
+
.with(kind_of(Integer), "sql.sequel", "", kind_of(String), 1)
|
19
19
|
|
20
20
|
db['SELECT 1'].all
|
21
21
|
end
|
@@ -11,13 +11,15 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
11
11
|
describe "#started" do
|
12
12
|
let(:event) do
|
13
13
|
double(
|
14
|
-
:request_id
|
15
|
-
:
|
14
|
+
:request_id => 1,
|
15
|
+
:command_name => 'find',
|
16
|
+
:command => {'foo' => 'bar'}
|
16
17
|
)
|
17
18
|
end
|
18
19
|
|
19
20
|
it "should sanitize command" do
|
20
|
-
Appsignal::
|
21
|
+
Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter
|
22
|
+
.should receive(:format).with('find', {'foo' => 'bar'})
|
21
23
|
|
22
24
|
subscriber.started(event)
|
23
25
|
end
|
@@ -81,8 +83,9 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
81
83
|
Appsignal::Extension.should receive(:finish_event).with(
|
82
84
|
transaction.transaction_index,
|
83
85
|
'query.mongodb',
|
84
|
-
'find',
|
85
|
-
"
|
86
|
+
'find | test | SUCCEEDED',
|
87
|
+
"{\"foo\":\"?\"}",
|
88
|
+
0
|
86
89
|
)
|
87
90
|
|
88
91
|
subscriber.finish('SUCCEEDED', event)
|
@@ -98,10 +98,10 @@ describe Appsignal::Subscriber do
|
|
98
98
|
|
99
99
|
it "should call native start and finish event for every event" do
|
100
100
|
Appsignal::Extension.should_receive(:start_event).exactly(4).times
|
101
|
-
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'one', '', '').once
|
102
|
-
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'two', '', '').once
|
103
|
-
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'two.three', '', '').once
|
104
|
-
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'one.three', '', '').once
|
101
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'one', '', '', 0).once
|
102
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'two', '', '', 0).once
|
103
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'two.three', '', '', 0).once
|
104
|
+
Appsignal::Extension.should_receive(:finish_event).with(kind_of(Integer), 'one.three', '', '', 0).once
|
105
105
|
|
106
106
|
ActiveSupport::Notifications.instrument('one') do
|
107
107
|
ActiveSupport::Notifications.instrument('two') do
|
@@ -119,7 +119,8 @@ describe Appsignal::Subscriber do
|
|
119
119
|
kind_of(Integer),
|
120
120
|
'request.net_http',
|
121
121
|
'GET http://www.google.com',
|
122
|
-
''
|
122
|
+
'',
|
123
|
+
0
|
123
124
|
).once
|
124
125
|
|
125
126
|
ActiveSupport::Notifications.instrument(
|
@@ -130,6 +131,23 @@ describe Appsignal::Subscriber do
|
|
130
131
|
)
|
131
132
|
end
|
132
133
|
|
134
|
+
it "should call finish with title, body and body format if there is a formatter that returns it" do
|
135
|
+
Appsignal::Extension.should_receive(:start_event).once
|
136
|
+
Appsignal::Extension.should_receive(:finish_event).with(
|
137
|
+
kind_of(Integer),
|
138
|
+
'sql.active_record',
|
139
|
+
'Something load',
|
140
|
+
'SELECT * FROM something',
|
141
|
+
1
|
142
|
+
).once
|
143
|
+
|
144
|
+
ActiveSupport::Notifications.instrument(
|
145
|
+
'sql.active_record',
|
146
|
+
:name => 'Something load',
|
147
|
+
:sql => 'SELECT * FROM something'
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
133
151
|
context "when paused" do
|
134
152
|
before { transaction.pause! }
|
135
153
|
|
@@ -331,6 +331,11 @@ describe Appsignal::Transaction do
|
|
331
331
|
'params',
|
332
332
|
'{"controller":"blog_posts","action":"show","id":"1"}'
|
333
333
|
).once
|
334
|
+
Appsignal::Extension.should_receive(:set_transaction_sample_data).with(
|
335
|
+
kind_of(Integer),
|
336
|
+
'metadata',
|
337
|
+
'{"key":"value"}'
|
338
|
+
).once
|
334
339
|
Appsignal::Extension.should_receive(:set_transaction_sample_data).with(
|
335
340
|
kind_of(Integer),
|
336
341
|
'tags',
|
@@ -616,6 +621,22 @@ describe Appsignal::Transaction do
|
|
616
621
|
end
|
617
622
|
end
|
618
623
|
|
624
|
+
describe "#metadata" do
|
625
|
+
subject { transaction.send(:metadata) }
|
626
|
+
|
627
|
+
context "when env is nil" do
|
628
|
+
before { transaction.request.stub(:env => nil) }
|
629
|
+
|
630
|
+
it { should be_nil }
|
631
|
+
end
|
632
|
+
|
633
|
+
context "when env is present" do
|
634
|
+
let(:env) { {:metadata => {:key => 'value'}} }
|
635
|
+
|
636
|
+
it { should == env[:metadata] }
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|
619
640
|
describe '#sanitized_tags' do
|
620
641
|
before do
|
621
642
|
transaction.set_tags(
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Appsignal::Utils do
|
@@ -33,4 +35,50 @@ describe Appsignal::Utils do
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
38
|
+
|
39
|
+
describe ".sanitize_key" do
|
40
|
+
it "should not sanitize key when no key_sanitizer is given" do
|
41
|
+
expect( Appsignal::Utils.sanitize_key('foo', nil) ).to eql('foo')
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with mongodb sanitizer" do
|
45
|
+
it "should not sanitize key when no dots are in the key" do
|
46
|
+
expect( Appsignal::Utils.sanitize_key('foo', :mongodb) ).to eql('foo')
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should sanitize key when dots are in the key" do
|
50
|
+
expect( Appsignal::Utils.sanitize_key('foo.bar', :mongodb) ).to eql('foo.?')
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should sanitize a symbol" do
|
54
|
+
expect( Appsignal::Utils.sanitize_key(:ismaster, :mongodb) ).to eql('ismaster')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe ".json_generate" do
|
60
|
+
subject { Appsignal::Utils.json_generate(body) }
|
61
|
+
|
62
|
+
context "with a valid body" do
|
63
|
+
let(:body) { {'the' => 'payload'} }
|
64
|
+
|
65
|
+
it { should == "{\"the\":\"payload\"}" }
|
66
|
+
end
|
67
|
+
|
68
|
+
context "with a body that contains strings with invalid utf-8 content" do
|
69
|
+
let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack('c*') }
|
70
|
+
let(:body) { {
|
71
|
+
'field_one' => [0x61, 0x61].pack('c*'),
|
72
|
+
'field_two' => string_with_invalid_utf8,
|
73
|
+
'field_three' => [
|
74
|
+
'one', string_with_invalid_utf8
|
75
|
+
],
|
76
|
+
'field_four' => {
|
77
|
+
'one' => string_with_invalid_utf8
|
78
|
+
}
|
79
|
+
} }
|
80
|
+
|
81
|
+
it { should == "{\"field_one\":\"aa\",\"field_two\":\"aa�\",\"field_three\":[\"one\",\"aa�\"],\"field_four\":{\"one\":\"aa�\"}}" }
|
82
|
+
end
|
83
|
+
end
|
36
84
|
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.1.0.beta.
|
4
|
+
version: 1.1.0.beta.7
|
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-
|
12
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -156,8 +156,10 @@ files:
|
|
156
156
|
- lib/appsignal/event_formatter/active_record/instantiation_formatter.rb
|
157
157
|
- lib/appsignal/event_formatter/active_record/sql_formatter.rb
|
158
158
|
- lib/appsignal/event_formatter/elastic_search/search_formatter.rb
|
159
|
+
- lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb
|
159
160
|
- lib/appsignal/event_formatter/moped/query_formatter.rb
|
160
161
|
- lib/appsignal/event_formatter/net_http/request_formatter.rb
|
162
|
+
- lib/appsignal/event_formatter/sequel/sql_formatter.rb
|
161
163
|
- lib/appsignal/extension.rb
|
162
164
|
- lib/appsignal/hooks.rb
|
163
165
|
- lib/appsignal/hooks/celluloid.rb
|
@@ -214,8 +216,10 @@ files:
|
|
214
216
|
- spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb
|
215
217
|
- spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb
|
216
218
|
- spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
|
219
|
+
- spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb
|
217
220
|
- spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb
|
218
221
|
- spec/lib/appsignal/event_formatter/net_http/request_formatter_spec.rb
|
222
|
+
- spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb
|
219
223
|
- spec/lib/appsignal/event_formatter_spec.rb
|
220
224
|
- spec/lib/appsignal/extension_spec.rb
|
221
225
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|
@@ -300,8 +304,10 @@ test_files:
|
|
300
304
|
- spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb
|
301
305
|
- spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb
|
302
306
|
- spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb
|
307
|
+
- spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb
|
303
308
|
- spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb
|
304
309
|
- spec/lib/appsignal/event_formatter/net_http/request_formatter_spec.rb
|
310
|
+
- spec/lib/appsignal/event_formatter/sequel/sql_formatter_spec.rb
|
305
311
|
- spec/lib/appsignal/event_formatter_spec.rb
|
306
312
|
- spec/lib/appsignal/extension_spec.rb
|
307
313
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|