appsignal 0.12.rc.12 → 0.12.rc.13
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/CHANGELOG.md +1 -0
- data/gemfiles/capistrano2.gemfile +1 -0
- data/gemfiles/capistrano3.gemfile +1 -0
- data/lib/appsignal.rb +1 -0
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +7 -30
- data/lib/appsignal/hooks.rb +1 -0
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +21 -0
- data/lib/appsignal/hooks/puma.rb +14 -0
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +50 -0
- data/lib/appsignal/transaction.rb +6 -1
- data/lib/appsignal/utils.rb +25 -0
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/capistrano2_spec.rb +7 -1
- data/spec/lib/appsignal/config_spec.rb +1 -1
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +0 -32
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +38 -0
- data/spec/lib/appsignal/hooks/puma_spec.rb +26 -2
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +125 -0
- data/spec/lib/appsignal/transaction_spec.rb +20 -0
- data/spec/lib/appsignal/utils_spec.rb +36 -0
- metadata +11 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e677ddb14f503c22d8a2f3f3019ef8ae6d6a4b5d
|
|
4
|
+
data.tar.gz: 5110ca959cf967f1d72c79a7fc3a3697f2d98f67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76d9f7df0f21d98a33040c4c11e4c8295f8677ff720ba6dec322514917ba342a3ce69c07cbc94f08d0a2e84cf425fb85d2cf128fd30a045a850cedb2076a552d
|
|
7
|
+
data.tar.gz: f5c1ff186860f7035d0c5127d9dd544fce3170dc17e047f2f7939df1d1bad60bac6abd59aa227561136a64ff97d63d0ab048343e1bae29ddba8e3227911e55aa
|
data/CHANGELOG.md
CHANGED
data/lib/appsignal.rb
CHANGED
|
@@ -11,12 +11,12 @@ module Appsignal
|
|
|
11
11
|
when 'Moped::Protocol::Command'
|
|
12
12
|
return ['Command', {
|
|
13
13
|
:database => op.full_collection_name,
|
|
14
|
-
:selector => sanitize(op.selector)
|
|
14
|
+
:selector => Appsignal::Utils.sanitize(op.selector)
|
|
15
15
|
}.inspect]
|
|
16
16
|
when 'Moped::Protocol::Query'
|
|
17
17
|
return ['Query', {
|
|
18
18
|
:database => op.full_collection_name,
|
|
19
|
-
:selector => sanitize(op.selector),
|
|
19
|
+
:selector => Appsignal::Utils.sanitize(op.selector),
|
|
20
20
|
:flags => op.flags,
|
|
21
21
|
:limit => op.limit,
|
|
22
22
|
:skip => op.skip,
|
|
@@ -25,21 +25,21 @@ module Appsignal
|
|
|
25
25
|
when 'Moped::Protocol::Delete'
|
|
26
26
|
return ['Delete', {
|
|
27
27
|
:database => op.full_collection_name,
|
|
28
|
-
:selector => sanitize(op.selector),
|
|
28
|
+
:selector => Appsignal::Utils.sanitize(op.selector),
|
|
29
29
|
:flags => op.flags,
|
|
30
30
|
}.inspect]
|
|
31
31
|
when 'Moped::Protocol::Insert'
|
|
32
32
|
return ['Insert', {
|
|
33
33
|
:database => op.full_collection_name,
|
|
34
|
-
:documents => sanitize(op.documents, true),
|
|
34
|
+
:documents => Appsignal::Utils.sanitize(op.documents, true),
|
|
35
35
|
:count => op.documents.count,
|
|
36
36
|
:flags => op.flags,
|
|
37
37
|
}.inspect]
|
|
38
38
|
when 'Moped::Protocol::Update'
|
|
39
39
|
return ['Update', {
|
|
40
40
|
:database => op.full_collection_name,
|
|
41
|
-
:selector => sanitize(op.selector),
|
|
42
|
-
:update => sanitize(op.update, true),
|
|
41
|
+
:selector => Appsignal::Utils.sanitize(op.selector),
|
|
42
|
+
:update => Appsignal::Utils.sanitize(op.update, true),
|
|
43
43
|
:flags => op.flags,
|
|
44
44
|
}.inspect]
|
|
45
45
|
when 'Moped::Protocol::KillCursors'
|
|
@@ -54,30 +54,7 @@ module Appsignal
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def sanitize(params, only_top_level=false)
|
|
60
|
-
if params.is_a?(Hash)
|
|
61
|
-
{}.tap do |hsh|
|
|
62
|
-
params.each do |key, val|
|
|
63
|
-
hsh[key] = only_top_level ? '?' : sanitize(val, only_top_level)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
elsif params.is_a?(Array)
|
|
67
|
-
if only_top_level
|
|
68
|
-
sanitize(params[0], only_top_level)
|
|
69
|
-
elsif params.first.is_a?(String)
|
|
70
|
-
['?']
|
|
71
|
-
else
|
|
72
|
-
params.map do |item|
|
|
73
|
-
sanitize(item, only_top_level)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
else
|
|
77
|
-
'?'
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
57
|
+
end
|
|
81
58
|
end
|
|
82
59
|
end
|
|
83
60
|
end
|
data/lib/appsignal/hooks.rb
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Appsignal
|
|
2
|
+
class Hooks
|
|
3
|
+
class MongoRubyDriverHook < Appsignal::Hooks::Hook
|
|
4
|
+
register :mongo_ruby_driver
|
|
5
|
+
|
|
6
|
+
def dependencies_present?
|
|
7
|
+
defined?(::Mongo::Monitoring::Global)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def install
|
|
11
|
+
require 'appsignal/integrations/mongo_ruby_driver'
|
|
12
|
+
|
|
13
|
+
Mongo::Monitoring::Global.subscribe(
|
|
14
|
+
Mongo::Monitoring::COMMAND,
|
|
15
|
+
Appsignal::Hooks::MongoMonitorSubscriber.new
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/appsignal/hooks/puma.rb
CHANGED
|
@@ -10,10 +10,24 @@ module Appsignal
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def install
|
|
13
|
+
::Puma.cli_config.options[:before_worker_boot] ||= []
|
|
14
|
+
::Puma.cli_config.options[:before_worker_boot] << Proc.new do |id|
|
|
15
|
+
Appsignal.forked
|
|
16
|
+
end
|
|
17
|
+
|
|
13
18
|
::Puma.cli_config.options[:before_worker_shutdown] ||= []
|
|
14
19
|
::Puma.cli_config.options[:before_worker_shutdown] << Proc.new do |id|
|
|
15
20
|
Appsignal.stop
|
|
16
21
|
end
|
|
22
|
+
|
|
23
|
+
::Puma::Cluster.class_eval do
|
|
24
|
+
alias stop_workers_without_appsignal stop_workers
|
|
25
|
+
|
|
26
|
+
def stop_workers
|
|
27
|
+
Appsignal.stop
|
|
28
|
+
stop_workers_without_appsignal
|
|
29
|
+
end
|
|
30
|
+
end
|
|
17
31
|
end
|
|
18
32
|
end
|
|
19
33
|
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Appsignal
|
|
2
|
+
class Hooks
|
|
3
|
+
class MongoMonitorSubscriber
|
|
4
|
+
|
|
5
|
+
# Called by Mongo::Monitor when query starts
|
|
6
|
+
def started(event)
|
|
7
|
+
return unless transaction = Appsignal::Transaction.current
|
|
8
|
+
return if transaction.paused?
|
|
9
|
+
|
|
10
|
+
# Store the query on the transaction, we need it when the event finishes
|
|
11
|
+
store = transaction.store('mongo_driver')
|
|
12
|
+
store[event.request_id] = Appsignal::Utils.sanitize(event.command)
|
|
13
|
+
|
|
14
|
+
# Start this event
|
|
15
|
+
Appsignal::Extension.start_event(transaction.transaction_index)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Called by Mongo::Monitor when query succeeds
|
|
19
|
+
def succeeded(event)
|
|
20
|
+
# Finish the event as succeeded
|
|
21
|
+
finish('SUCCEEDED', event)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Called by Mongo::Monitor when query fails
|
|
25
|
+
def failed(event)
|
|
26
|
+
# Finish the event as failed
|
|
27
|
+
finish('FAILED', event)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Finishes the event in the AppSignal extension
|
|
31
|
+
def finish(result, event)
|
|
32
|
+
return unless transaction = Appsignal::Transaction.current
|
|
33
|
+
return if transaction.paused?
|
|
34
|
+
|
|
35
|
+
# Get the query from the transaction store
|
|
36
|
+
store = transaction.store('mongo_driver')
|
|
37
|
+
command = store[event.request_id].inspect
|
|
38
|
+
|
|
39
|
+
# Finish the event in the extension.
|
|
40
|
+
Appsignal::Extension.finish_event(
|
|
41
|
+
transaction.transaction_index,
|
|
42
|
+
'query.mongodb',
|
|
43
|
+
event.command_name.to_s,
|
|
44
|
+
%Q(#{event.database_name} | #{result} | #{command})
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -42,7 +42,7 @@ module Appsignal
|
|
|
42
42
|
@request = request
|
|
43
43
|
@paused = false
|
|
44
44
|
@tags = {}
|
|
45
|
-
|
|
45
|
+
@store = Hash.new({})
|
|
46
46
|
@options = options
|
|
47
47
|
@options[:params_method] ||= :params
|
|
48
48
|
|
|
@@ -68,6 +68,10 @@ module Appsignal
|
|
|
68
68
|
@paused == true
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
def store(key)
|
|
72
|
+
@store[key]
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
def set_tags(given_tags={})
|
|
72
76
|
@tags.merge!(given_tags)
|
|
73
77
|
end
|
|
@@ -128,6 +132,7 @@ module Appsignal
|
|
|
128
132
|
|
|
129
133
|
def set_error(error)
|
|
130
134
|
return unless error
|
|
135
|
+
return unless Appsignal.active?
|
|
131
136
|
return if Appsignal.is_ignored_error?(error)
|
|
132
137
|
|
|
133
138
|
Appsignal.logger.debug("Adding #{error.class.name} to transaction: #{transaction_id}")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Appsignal
|
|
2
|
+
module Utils
|
|
3
|
+
def self.sanitize(params, only_top_level=false)
|
|
4
|
+
if params.is_a?(Hash)
|
|
5
|
+
{}.tap do |hsh|
|
|
6
|
+
params.each do |key, val|
|
|
7
|
+
hsh[key] = only_top_level ? '?' : sanitize(val, only_top_level)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
elsif params.is_a?(Array)
|
|
11
|
+
if only_top_level
|
|
12
|
+
sanitize(params[0], only_top_level)
|
|
13
|
+
elsif params.first.is_a?(String)
|
|
14
|
+
['?']
|
|
15
|
+
else
|
|
16
|
+
params.map do |item|
|
|
17
|
+
sanitize(item, only_top_level)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
else
|
|
21
|
+
'?'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/appsignal/version.rb
CHANGED
|
@@ -169,7 +169,13 @@ if capistrano2_present?
|
|
|
169
169
|
it "should not send deploy marker" do
|
|
170
170
|
Appsignal::Marker.should_not_receive(:new)
|
|
171
171
|
@capistrano_config.find_and_execute_task('appsignal:deploy')
|
|
172
|
-
@io.string.
|
|
172
|
+
@io.string.encode(
|
|
173
|
+
'UTF-8',
|
|
174
|
+
'binary',
|
|
175
|
+
:invalid => :replace,
|
|
176
|
+
:undef => :replace,
|
|
177
|
+
:replace => ''
|
|
178
|
+
).should include("config for 'nonsense' not found")
|
|
173
179
|
end
|
|
174
180
|
end
|
|
175
181
|
end
|
|
@@ -43,7 +43,7 @@ describe Appsignal::Config do
|
|
|
43
43
|
its(:log_file_path) { should end_with('/tmp/appsignal.log') }
|
|
44
44
|
|
|
45
45
|
context "if it is not writable" do
|
|
46
|
-
let(:config) { project_fixture_config('production', :log_path => '/
|
|
46
|
+
let(:config) { project_fixture_config('production', :log_path => '/non-existing') }
|
|
47
47
|
|
|
48
48
|
its(:log_file_path) { should == '/tmp/appsignal.log' }
|
|
49
49
|
end
|
|
@@ -112,36 +112,4 @@ describe Appsignal::EventFormatter::Moped::QueryFormatter do
|
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
115
|
-
describe "#sanitize" do
|
|
116
|
-
context "when params is a hash" do
|
|
117
|
-
let(:params) { {'foo' => 'bar'} }
|
|
118
|
-
|
|
119
|
-
it "should sanitize all hash values with a questionmark" do
|
|
120
|
-
expect( formatter.send(:sanitize, params) ).to eq('foo' => '?')
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
context "when params is an array of hashes" do
|
|
125
|
-
let(:params) { [{'foo' => 'bar'}] }
|
|
126
|
-
|
|
127
|
-
it "should sanitize all hash values with a questionmark" do
|
|
128
|
-
expect( formatter.send(:sanitize, params) ).to eq([{'foo' => '?'}])
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context "when params is an array of strings " do
|
|
133
|
-
let(:params) { ['foo', 'bar'] }
|
|
134
|
-
|
|
135
|
-
it "should sanitize all hash values with a single questionmark" do
|
|
136
|
-
expect( formatter.send(:sanitize, params) ).to eq(['?'])
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
context "when params is a string" do
|
|
140
|
-
let(:params) { 'bar'}
|
|
141
|
-
|
|
142
|
-
it "should sanitize all hash values with a questionmark" do
|
|
143
|
-
expect( formatter.send(:sanitize, params) ).to eq('?')
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
115
|
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Appsignal::Hooks::MongoRubyDriverHook do
|
|
4
|
+
require 'appsignal/integrations/mongo_ruby_driver'
|
|
5
|
+
|
|
6
|
+
context "with mongo ruby driver" do
|
|
7
|
+
let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
|
|
8
|
+
before { Appsignal::Hooks::MongoMonitorSubscriber.stub(:new => subscriber) }
|
|
9
|
+
|
|
10
|
+
before(:all) do
|
|
11
|
+
module Mongo
|
|
12
|
+
module Monitoring
|
|
13
|
+
COMMAND = 'command'
|
|
14
|
+
|
|
15
|
+
class Global
|
|
16
|
+
def subscribe
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
after(:all) { Object.send(:remove_const, :Mongo) }
|
|
23
|
+
|
|
24
|
+
its(:dependencies_present?) { should be_true }
|
|
25
|
+
|
|
26
|
+
it "adds a subscriber to Mongo::Monitoring" do
|
|
27
|
+
Mongo::Monitoring::Global.should receive(:subscribe)
|
|
28
|
+
.with('command', subscriber)
|
|
29
|
+
.at_least(:once)
|
|
30
|
+
|
|
31
|
+
Appsignal::Hooks::MongoRubyDriverHook.new.install
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context "without mongo ruby driver" do
|
|
36
|
+
its(:dependencies_present?) { should be_false }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -7,6 +7,11 @@ describe Appsignal::Hooks::PumaHook do
|
|
|
7
7
|
def self.cli_config
|
|
8
8
|
@cli_config ||= CliConfig.new
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
class Cluster
|
|
12
|
+
def stop_workers
|
|
13
|
+
end
|
|
14
|
+
end
|
|
10
15
|
end
|
|
11
16
|
|
|
12
17
|
class CliConfig
|
|
@@ -21,24 +26,43 @@ describe Appsignal::Hooks::PumaHook do
|
|
|
21
26
|
|
|
22
27
|
its(:dependencies_present?) { should be_true }
|
|
23
28
|
|
|
24
|
-
context "
|
|
29
|
+
context "when installed" do
|
|
30
|
+
before do
|
|
31
|
+
Appsignal::Hooks::PumaHook.new.install
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "adds behavior to Unicorn::Worker#close" do
|
|
35
|
+
cluster = Puma::Cluster.new
|
|
36
|
+
|
|
37
|
+
Appsignal.should_receive(:stop)
|
|
38
|
+
cluster.should_receive(:stop_workers_without_appsignal)
|
|
39
|
+
|
|
40
|
+
cluster.stop_workers
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context "with nil hooks" do
|
|
25
45
|
before do
|
|
46
|
+
Puma.cli_config.options.delete(:before_worker_boot)
|
|
26
47
|
Puma.cli_config.options.delete(:before_worker_shutdown)
|
|
27
48
|
Appsignal::Hooks::PumaHook.new.install
|
|
28
49
|
end
|
|
29
50
|
|
|
30
51
|
it "should add a before shutdown worker callback" do
|
|
52
|
+
Puma.cli_config.options[:before_worker_boot].first.should be_a(Proc)
|
|
31
53
|
Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc)
|
|
32
54
|
end
|
|
33
55
|
end
|
|
34
56
|
|
|
35
|
-
context "with
|
|
57
|
+
context "with existing hooks" do
|
|
36
58
|
before do
|
|
59
|
+
Puma.cli_config.options[:before_worker_boot] = []
|
|
37
60
|
Puma.cli_config.options[:before_worker_shutdown] = []
|
|
38
61
|
Appsignal::Hooks::PumaHook.new.install
|
|
39
62
|
end
|
|
40
63
|
|
|
41
64
|
it "should add a before shutdown worker callback" do
|
|
65
|
+
Puma.cli_config.options[:before_worker_boot].first.should be_a(Proc)
|
|
42
66
|
Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc)
|
|
43
67
|
end
|
|
44
68
|
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'appsignal/integrations/mongo_ruby_driver'
|
|
3
|
+
describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
4
|
+
let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
|
|
5
|
+
|
|
6
|
+
context "with transaction" do
|
|
7
|
+
let!(:transaction) do
|
|
8
|
+
Appsignal::Transaction.create('1', 'http_request', {}, {})
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "#started" do
|
|
12
|
+
let(:event) do
|
|
13
|
+
double(
|
|
14
|
+
:request_id => 1,
|
|
15
|
+
:command => {'foo' => 'bar'}
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should sanitize command" do
|
|
20
|
+
Appsignal::Utils.should receive(:sanitize).with({'foo' => 'bar'} )
|
|
21
|
+
|
|
22
|
+
subscriber.started(event)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should store command on the transaction" do
|
|
26
|
+
subscriber.started(event)
|
|
27
|
+
|
|
28
|
+
transaction.store('mongo_driver').should == { 1 => {'foo' => '?'}}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should start an event in the extension" do
|
|
32
|
+
Appsignal::Extension.should receive(:start_event)
|
|
33
|
+
.with(transaction.transaction_index)
|
|
34
|
+
|
|
35
|
+
subscriber.started(event)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe "#succeeded" do
|
|
40
|
+
let(:event) { double }
|
|
41
|
+
|
|
42
|
+
it "should finish the event" do
|
|
43
|
+
subscriber.should receive(:finish).with('SUCCEEDED', event)
|
|
44
|
+
|
|
45
|
+
subscriber.succeeded(event)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
describe "#failed" do
|
|
50
|
+
let(:event) { double }
|
|
51
|
+
|
|
52
|
+
it "should finish the event" do
|
|
53
|
+
subscriber.should receive(:finish).with('FAILED', event)
|
|
54
|
+
|
|
55
|
+
subscriber.failed(event)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
describe "#finish" do
|
|
60
|
+
let(:command) { {'foo' => '?'} }
|
|
61
|
+
let(:event) do
|
|
62
|
+
double(
|
|
63
|
+
:request_id => 2,
|
|
64
|
+
:command_name => :find,
|
|
65
|
+
:database_name => 'test'
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
before do
|
|
70
|
+
store = transaction.store('mongo_driver')
|
|
71
|
+
store[2] = command
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it "should get the query from the store" do
|
|
75
|
+
transaction.should receive(:store).with('mongo_driver').and_return(command)
|
|
76
|
+
|
|
77
|
+
subscriber.finish('SUCCEEDED', event)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should finish the transaction in the extension" do
|
|
81
|
+
Appsignal::Extension.should receive(:finish_event).with(
|
|
82
|
+
transaction.transaction_index,
|
|
83
|
+
'query.mongodb',
|
|
84
|
+
'find',
|
|
85
|
+
"test | SUCCEEDED | {\"foo\"=>\"?\"}"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
subscriber.finish('SUCCEEDED', event)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "without transaction" do
|
|
94
|
+
before { Appsignal::Transaction.stub(:current => nil) }
|
|
95
|
+
|
|
96
|
+
it "should not attempt to start an event" do
|
|
97
|
+
Appsignal::Extension.should_not receive(:start_event)
|
|
98
|
+
|
|
99
|
+
subscriber.started(double)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should not attempt to finish an event" do
|
|
103
|
+
Appsignal::Extension.should_not receive(:finish_event)
|
|
104
|
+
|
|
105
|
+
subscriber.finish('SUCCEEDED', double)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
context "when appsignal is paused" do
|
|
110
|
+
let(:transaction) { double(:paused? => true) }
|
|
111
|
+
before { Appsignal::Transaction.stub(:current => transaction) }
|
|
112
|
+
|
|
113
|
+
it "should not attempt to start an event" do
|
|
114
|
+
Appsignal::Extension.should_not receive(:start_event)
|
|
115
|
+
|
|
116
|
+
subscriber.started(double)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "should not attempt to finish an event" do
|
|
120
|
+
Appsignal::Extension.should_not receive(:finish_event)
|
|
121
|
+
|
|
122
|
+
subscriber.finish('SUCCEEDED', double)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -149,6 +149,19 @@ describe Appsignal::Transaction do
|
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
|
|
152
|
+
describe "#store" do
|
|
153
|
+
it "should return an empty store when it's not already present" do
|
|
154
|
+
expect( transaction.store('test') ).to eql({})
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "should store changes to the store" do
|
|
158
|
+
transaction_store = transaction.store('test')
|
|
159
|
+
transaction_store['transaction'] = 'value'
|
|
160
|
+
|
|
161
|
+
expect( transaction.store('test') ).to eql({'transaction' => 'value'})
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
152
165
|
describe "#set_tags" do
|
|
153
166
|
it "should add tags to transaction" do
|
|
154
167
|
expect {
|
|
@@ -332,6 +345,13 @@ describe Appsignal::Transaction do
|
|
|
332
345
|
transaction.set_error(error)
|
|
333
346
|
end
|
|
334
347
|
|
|
348
|
+
it "should not add the error if appsignal is not active" do
|
|
349
|
+
Appsignal.stub(:active? => false)
|
|
350
|
+
Appsignal::Extension.should_not_receive(:set_transaction_error)
|
|
351
|
+
|
|
352
|
+
transaction.set_error(error)
|
|
353
|
+
end
|
|
354
|
+
|
|
335
355
|
context "for a http request" do
|
|
336
356
|
it "should set an error in the extension" do
|
|
337
357
|
Appsignal::Extension.should_receive(:set_transaction_error).with(
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Appsignal::Utils do
|
|
4
|
+
describe ".sanitize" do
|
|
5
|
+
context "when params is a hash" do
|
|
6
|
+
let(:params) { {'foo' => 'bar'} }
|
|
7
|
+
|
|
8
|
+
it "should sanitize all hash values with a questionmark" do
|
|
9
|
+
expect( Appsignal::Utils.sanitize(params) ).to eq('foo' => '?')
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "when params is an array of hashes" do
|
|
14
|
+
let(:params) { [{'foo' => 'bar'}] }
|
|
15
|
+
|
|
16
|
+
it "should sanitize all hash values with a questionmark" do
|
|
17
|
+
expect( Appsignal::Utils.sanitize(params) ).to eq([{'foo' => '?'}])
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context "when params is an array of strings " do
|
|
22
|
+
let(:params) { ['foo', 'bar'] }
|
|
23
|
+
|
|
24
|
+
it "should sanitize all hash values with a single questionmark" do
|
|
25
|
+
expect( Appsignal::Utils.sanitize(params) ).to eq(['?'])
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
context "when params is a string" do
|
|
29
|
+
let(:params) { 'bar'}
|
|
30
|
+
|
|
31
|
+
it "should sanitize all hash values with a questionmark" do
|
|
32
|
+
expect( Appsignal::Utils.sanitize(params) ).to eq('?')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
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: 0.12.rc.
|
|
4
|
+
version: 0.12.rc.13
|
|
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: 2015-12-
|
|
12
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rack
|
|
@@ -156,6 +156,7 @@ files:
|
|
|
156
156
|
- lib/appsignal/hooks.rb
|
|
157
157
|
- lib/appsignal/hooks/celluloid.rb
|
|
158
158
|
- lib/appsignal/hooks/delayed_job.rb
|
|
159
|
+
- lib/appsignal/hooks/mongo_ruby_driver.rb
|
|
159
160
|
- lib/appsignal/hooks/net_http.rb
|
|
160
161
|
- lib/appsignal/hooks/passenger.rb
|
|
161
162
|
- lib/appsignal/hooks/puma.rb
|
|
@@ -169,6 +170,7 @@ files:
|
|
|
169
170
|
- lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
|
|
170
171
|
- lib/appsignal/integrations/capistrano/careful_logger.rb
|
|
171
172
|
- lib/appsignal/integrations/delayed_job_plugin.rb
|
|
173
|
+
- lib/appsignal/integrations/mongo_ruby_driver.rb
|
|
172
174
|
- lib/appsignal/integrations/padrino.rb
|
|
173
175
|
- lib/appsignal/integrations/railtie.rb
|
|
174
176
|
- lib/appsignal/integrations/sinatra.rb
|
|
@@ -182,6 +184,7 @@ files:
|
|
|
182
184
|
- lib/appsignal/subscriber.rb
|
|
183
185
|
- lib/appsignal/transaction.rb
|
|
184
186
|
- lib/appsignal/transmitter.rb
|
|
187
|
+
- lib/appsignal/utils.rb
|
|
185
188
|
- lib/appsignal/version.rb
|
|
186
189
|
- lib/generators/appsignal/USAGE
|
|
187
190
|
- lib/generators/appsignal/appsignal_generator.rb
|
|
@@ -205,6 +208,7 @@ files:
|
|
|
205
208
|
- spec/lib/appsignal/extension_spec.rb
|
|
206
209
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|
|
207
210
|
- spec/lib/appsignal/hooks/delayed_job_spec.rb
|
|
211
|
+
- spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
|
|
208
212
|
- spec/lib/appsignal/hooks/net_http_spec.rb
|
|
209
213
|
- spec/lib/appsignal/hooks/passenger_spec.rb
|
|
210
214
|
- spec/lib/appsignal/hooks/puma_spec.rb
|
|
@@ -215,6 +219,7 @@ files:
|
|
|
215
219
|
- spec/lib/appsignal/hooks/sidekiq_spec.rb
|
|
216
220
|
- spec/lib/appsignal/hooks/unicorn_spec.rb
|
|
217
221
|
- spec/lib/appsignal/hooks_spec.rb
|
|
222
|
+
- spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
|
|
218
223
|
- spec/lib/appsignal/integrations/padrino_spec.rb
|
|
219
224
|
- spec/lib/appsignal/integrations/railtie_spec.rb
|
|
220
225
|
- spec/lib/appsignal/integrations/sinatra_spec.rb
|
|
@@ -228,6 +233,7 @@ files:
|
|
|
228
233
|
- spec/lib/appsignal/subscriber_spec.rb
|
|
229
234
|
- spec/lib/appsignal/transaction_spec.rb
|
|
230
235
|
- spec/lib/appsignal/transmitter_spec.rb
|
|
236
|
+
- spec/lib/appsignal/utils_spec.rb
|
|
231
237
|
- spec/lib/appsignal_spec.rb
|
|
232
238
|
- spec/lib/generators/appsignal/appsignal_generator_spec.rb
|
|
233
239
|
- spec/lib/tmp/config/appsignal.yml
|
|
@@ -283,6 +289,7 @@ test_files:
|
|
|
283
289
|
- spec/lib/appsignal/extension_spec.rb
|
|
284
290
|
- spec/lib/appsignal/hooks/celluloid_spec.rb
|
|
285
291
|
- spec/lib/appsignal/hooks/delayed_job_spec.rb
|
|
292
|
+
- spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
|
|
286
293
|
- spec/lib/appsignal/hooks/net_http_spec.rb
|
|
287
294
|
- spec/lib/appsignal/hooks/passenger_spec.rb
|
|
288
295
|
- spec/lib/appsignal/hooks/puma_spec.rb
|
|
@@ -293,6 +300,7 @@ test_files:
|
|
|
293
300
|
- spec/lib/appsignal/hooks/sidekiq_spec.rb
|
|
294
301
|
- spec/lib/appsignal/hooks/unicorn_spec.rb
|
|
295
302
|
- spec/lib/appsignal/hooks_spec.rb
|
|
303
|
+
- spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
|
|
296
304
|
- spec/lib/appsignal/integrations/padrino_spec.rb
|
|
297
305
|
- spec/lib/appsignal/integrations/railtie_spec.rb
|
|
298
306
|
- spec/lib/appsignal/integrations/sinatra_spec.rb
|
|
@@ -306,6 +314,7 @@ test_files:
|
|
|
306
314
|
- spec/lib/appsignal/subscriber_spec.rb
|
|
307
315
|
- spec/lib/appsignal/transaction_spec.rb
|
|
308
316
|
- spec/lib/appsignal/transmitter_spec.rb
|
|
317
|
+
- spec/lib/appsignal/utils_spec.rb
|
|
309
318
|
- spec/lib/appsignal_spec.rb
|
|
310
319
|
- spec/lib/generators/appsignal/appsignal_generator_spec.rb
|
|
311
320
|
- spec/lib/tmp/config/appsignal.yml
|