appsignal 2.1.0.beta.1 → 2.1.0
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/.rspec +2 -1
- data/CHANGELOG.md +5 -0
- data/README.md +14 -15
- data/appsignal.gemspec +1 -1
- data/lib/appsignal.rb +1 -1
- data/lib/appsignal/auth_check.rb +5 -2
- data/lib/appsignal/cli/demo.rb +1 -1
- data/lib/appsignal/cli/diagnose.rb +1 -1
- data/lib/appsignal/cli/install.rb +1 -1
- data/lib/appsignal/transaction.rb +2 -1
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/auth_check_spec.rb +9 -10
- data/spec/lib/appsignal/capistrano2_spec.rb +6 -6
- data/spec/lib/appsignal/capistrano3_spec.rb +6 -6
- data/spec/lib/appsignal/cli/demo_spec.rb +1 -1
- data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
- data/spec/lib/appsignal/cli/helpers_spec.rb +2 -2
- data/spec/lib/appsignal/cli/install_spec.rb +2 -2
- data/spec/lib/appsignal/cli_spec.rb +2 -2
- data/spec/lib/appsignal/config_spec.rb +24 -24
- data/spec/lib/appsignal/demo_spec.rb +4 -2
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +11 -7
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +2 -2
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +2 -2
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +1 -1
- data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +2 -2
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +9 -9
- data/spec/lib/appsignal/event_formatter_spec.rb +17 -17
- data/spec/lib/appsignal/extension_spec.rb +7 -7
- data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +0 -3
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +11 -3
- data/spec/lib/appsignal/hooks/celluloid_spec.rb +12 -4
- data/spec/lib/appsignal/hooks/data_mapper_spec.rb +12 -4
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +21 -13
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +14 -6
- data/spec/lib/appsignal/hooks/net_http_spec.rb +11 -3
- data/spec/lib/appsignal/hooks/passenger_spec.rb +14 -6
- data/spec/lib/appsignal/hooks/puma_spec.rb +18 -10
- data/spec/lib/appsignal/hooks/rake_spec.rb +2 -2
- data/spec/lib/appsignal/hooks/redis_spec.rb +40 -30
- data/spec/lib/appsignal/hooks/sequel_spec.rb +11 -3
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +15 -7
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +17 -9
- data/spec/lib/appsignal/hooks/unicorn_spec.rb +16 -8
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +14 -4
- data/spec/lib/appsignal/hooks_spec.rb +28 -28
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/grape_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +14 -16
- data/spec/lib/appsignal/integrations/object_spec.rb +10 -10
- data/spec/lib/appsignal/integrations/padrino_spec.rb +14 -18
- data/spec/lib/appsignal/integrations/railtie_spec.rb +35 -19
- data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +2 -2
- data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +1 -1
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +1 -1
- data/spec/lib/appsignal/minutely_spec.rb +3 -3
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +12 -12
- data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +2 -2
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +19 -15
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +5 -5
- data/spec/lib/appsignal/system_spec.rb +5 -5
- data/spec/lib/appsignal/transaction_spec.rb +176 -155
- data/spec/lib/appsignal/transmitter_spec.rb +29 -23
- data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +49 -35
- data/spec/lib/appsignal/utils_spec.rb +15 -8
- data/spec/lib/appsignal_spec.rb +134 -150
- data/spec/spec_helper.rb +5 -2
- metadata +6 -10
- data/spec/lib/tmp/config/appsignal.yml +0 -2
- data/spec/support/delegate_matcher.rb +0 -38
@@ -15,13 +15,13 @@ describe Appsignal::Hooks::SidekiqPlugin do
|
|
15
15
|
let(:plugin) { Appsignal::Hooks::SidekiqPlugin.new }
|
16
16
|
|
17
17
|
before do
|
18
|
-
Appsignal::Transaction.
|
18
|
+
allow(Appsignal::Transaction).to receive(:current).and_return(current_transaction)
|
19
19
|
start_agent
|
20
20
|
end
|
21
21
|
|
22
22
|
context "with a performance call" do
|
23
23
|
it "should wrap in a transaction with the correct params" do
|
24
|
-
Appsignal.
|
24
|
+
expect(Appsignal).to receive(:monitor_transaction).with(
|
25
25
|
"perform_job.sidekiq",
|
26
26
|
:class => "TestClass",
|
27
27
|
:method => "perform",
|
@@ -56,7 +56,7 @@ describe Appsignal::Hooks::SidekiqPlugin do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should wrap in a transaction with the correct params" do
|
59
|
-
Appsignal.
|
59
|
+
expect(Appsignal).to receive(:monitor_transaction).with(
|
60
60
|
"perform_job.sidekiq",
|
61
61
|
:class => "TestClass",
|
62
62
|
:method => "perform",
|
@@ -83,7 +83,7 @@ describe Appsignal::Hooks::SidekiqPlugin do
|
|
83
83
|
let(:error) { VerySpecificError.new }
|
84
84
|
|
85
85
|
it "should add the exception to appsignal" do
|
86
|
-
Appsignal::Transaction.
|
86
|
+
expect_any_instance_of(Appsignal::Transaction).to receive(:set_error).with(error)
|
87
87
|
end
|
88
88
|
|
89
89
|
after do
|
@@ -107,26 +107,34 @@ describe Appsignal::Hooks::SidekiqPlugin do
|
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should only add items to the hash that do not appear in JOB_KEYS" do
|
110
|
-
plugin.formatted_metadata(item).
|
110
|
+
expect(plugin.formatted_metadata(item)).to eq("foo" => "bar")
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
describe Appsignal::Hooks::SidekiqHook do
|
116
116
|
context "with sidekiq" do
|
117
|
-
before :
|
117
|
+
before :context do
|
118
118
|
module Sidekiq
|
119
119
|
def self.configure_server
|
120
120
|
end
|
121
121
|
end
|
122
122
|
Appsignal::Hooks::SidekiqHook.new.install
|
123
123
|
end
|
124
|
-
after(:
|
124
|
+
after(:context) { Object.send(:remove_const, :Sidekiq) }
|
125
125
|
|
126
|
-
|
126
|
+
describe "#dependencies_present?" do
|
127
|
+
subject { described_class.new.dependencies_present? }
|
128
|
+
|
129
|
+
it { is_expected.to be_truthy }
|
130
|
+
end
|
127
131
|
end
|
128
132
|
|
129
133
|
context "without sidekiq" do
|
130
|
-
|
134
|
+
describe "#dependencies_present?" do
|
135
|
+
subject { described_class.new.dependencies_present? }
|
136
|
+
|
137
|
+
it { is_expected.to be_falsy }
|
138
|
+
end
|
131
139
|
end
|
132
140
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
describe Appsignal::Hooks::UnicornHook do
|
2
2
|
context "with unicorn" do
|
3
|
-
before :
|
3
|
+
before :context do
|
4
4
|
module Unicorn
|
5
5
|
class HttpServer
|
6
6
|
def worker_loop(worker)
|
@@ -14,16 +14,20 @@ describe Appsignal::Hooks::UnicornHook do
|
|
14
14
|
end
|
15
15
|
Appsignal::Hooks::UnicornHook.new.install
|
16
16
|
end
|
17
|
-
after(:
|
17
|
+
after(:context) { Object.send(:remove_const, :Unicorn) }
|
18
18
|
|
19
|
-
|
19
|
+
describe "#dependencies_present?" do
|
20
|
+
subject { described_class.new.dependencies_present? }
|
21
|
+
|
22
|
+
it { is_expected.to be_truthy }
|
23
|
+
end
|
20
24
|
|
21
25
|
it "adds behavior to Unicorn::HttpServer#worker_loop" do
|
22
26
|
server = Unicorn::HttpServer.new
|
23
27
|
worker = double
|
24
28
|
|
25
|
-
Appsignal.
|
26
|
-
server.
|
29
|
+
expect(Appsignal).to receive(:forked)
|
30
|
+
expect(server).to receive(:worker_loop_without_appsignal).with(worker)
|
27
31
|
|
28
32
|
server.worker_loop(worker)
|
29
33
|
end
|
@@ -31,14 +35,18 @@ describe Appsignal::Hooks::UnicornHook do
|
|
31
35
|
it "adds behavior to Unicorn::Worker#close" do
|
32
36
|
worker = Unicorn::Worker.new
|
33
37
|
|
34
|
-
Appsignal.
|
35
|
-
worker.
|
38
|
+
expect(Appsignal).to receive(:stop)
|
39
|
+
expect(worker).to receive(:close_without_appsignal)
|
36
40
|
|
37
41
|
worker.close
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
45
|
context "without unicorn" do
|
42
|
-
|
46
|
+
describe "#dependencies_present?" do
|
47
|
+
subject { described_class.new.dependencies_present? }
|
48
|
+
|
49
|
+
it { is_expected.to be_falsy }
|
50
|
+
end
|
43
51
|
end
|
44
52
|
end
|
@@ -2,9 +2,13 @@ describe Appsignal::Hooks::WebmachineHook do
|
|
2
2
|
if DependencyHelper.webmachine_present?
|
3
3
|
context "with webmachine" do
|
4
4
|
let(:fsm) { Webmachine::Decision::FSM.new(double(:trace? => false), double, double) }
|
5
|
-
before(:
|
5
|
+
before(:context) { start_agent }
|
6
6
|
|
7
|
-
|
7
|
+
describe "#dependencies_present?" do
|
8
|
+
subject { described_class.new.dependencies_present? }
|
9
|
+
|
10
|
+
it { is_expected.to be_truthy }
|
11
|
+
end
|
8
12
|
|
9
13
|
it "should include the run alias methods" do
|
10
14
|
expect(fsm).to respond_to(:run_with_appsignal)
|
@@ -14,12 +18,18 @@ describe Appsignal::Hooks::WebmachineHook do
|
|
14
18
|
it "should include the handle_exceptions alias methods" do
|
15
19
|
expect(
|
16
20
|
fsm.respond_to?(:handle_exceptions_with_appsignal, true)
|
17
|
-
).to
|
21
|
+
).to be_truthy
|
18
22
|
|
19
23
|
expect(
|
20
24
|
fsm.respond_to?(:handle_exceptions_without_appsignal, true)
|
21
|
-
).to
|
25
|
+
).to be_truthy
|
22
26
|
end
|
23
27
|
end
|
28
|
+
else
|
29
|
+
describe "#dependencies_present?" do
|
30
|
+
subject { described_class.new.dependencies_present? }
|
31
|
+
|
32
|
+
it { is_expected.to be_falsy }
|
33
|
+
end
|
24
34
|
end
|
25
35
|
end
|
@@ -35,43 +35,43 @@ describe Appsignal::Hooks do
|
|
35
35
|
it "should register and install a hook once" do
|
36
36
|
Appsignal::Hooks::Hook.register(:mock_present_hook, MockPresentHook)
|
37
37
|
|
38
|
-
Appsignal::Hooks.hooks[:mock_present_hook].
|
39
|
-
Appsignal::Hooks.hooks[:mock_present_hook].installed
|
38
|
+
expect(Appsignal::Hooks.hooks[:mock_present_hook]).to be_instance_of(MockPresentHook)
|
39
|
+
expect(Appsignal::Hooks.hooks[:mock_present_hook].installed?).to be_falsy
|
40
40
|
|
41
|
-
MockPresentHook.
|
41
|
+
expect(MockPresentHook).to receive(:call_something).once
|
42
42
|
|
43
43
|
Appsignal::Hooks.load_hooks
|
44
44
|
Appsignal::Hooks.load_hooks
|
45
45
|
Appsignal::Hooks.load_hooks
|
46
|
-
Appsignal::Hooks.hooks[:mock_present_hook].installed
|
46
|
+
expect(Appsignal::Hooks.hooks[:mock_present_hook].installed?).to be_truthy
|
47
47
|
Appsignal::Hooks.hooks.delete(:mock_present_hook)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should not install if depencies are not present" do
|
51
51
|
Appsignal::Hooks::Hook.register(:mock_not_present_hook, MockNotPresentHook)
|
52
52
|
|
53
|
-
Appsignal::Hooks.hooks[:mock_not_present_hook].
|
54
|
-
Appsignal::Hooks.hooks[:mock_not_present_hook].installed
|
53
|
+
expect(Appsignal::Hooks.hooks[:mock_not_present_hook]).to be_instance_of(MockNotPresentHook)
|
54
|
+
expect(Appsignal::Hooks.hooks[:mock_not_present_hook].installed?).to be_falsy
|
55
55
|
|
56
|
-
MockPresentHook.
|
56
|
+
expect(MockPresentHook).to_not receive(:call_something)
|
57
57
|
|
58
58
|
Appsignal::Hooks.load_hooks
|
59
59
|
|
60
|
-
Appsignal::Hooks.hooks[:mock_not_present_hook].installed
|
60
|
+
expect(Appsignal::Hooks.hooks[:mock_not_present_hook].installed?).to be_falsy
|
61
61
|
Appsignal::Hooks.hooks.delete(:mock_not_present_hook)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should not install if there is an error while installing" do
|
65
65
|
Appsignal::Hooks::Hook.register(:mock_error_hook, MockErrorHook)
|
66
66
|
|
67
|
-
Appsignal::Hooks.hooks[:mock_error_hook].
|
68
|
-
Appsignal::Hooks.hooks[:mock_error_hook].installed
|
67
|
+
expect(Appsignal::Hooks.hooks[:mock_error_hook]).to be_instance_of(MockErrorHook)
|
68
|
+
expect(Appsignal::Hooks.hooks[:mock_error_hook].installed?).to be_falsy
|
69
69
|
|
70
|
-
Appsignal.logger.
|
70
|
+
expect(Appsignal.logger).to receive(:error).with("Error while installing mock_error_hook hook: error").once
|
71
71
|
|
72
72
|
Appsignal::Hooks.load_hooks
|
73
73
|
|
74
|
-
Appsignal::Hooks.hooks[:mock_error_hook].installed
|
74
|
+
expect(Appsignal::Hooks.hooks[:mock_error_hook].installed?).to be_falsy
|
75
75
|
Appsignal::Hooks.hooks.delete(:mock_error_hook)
|
76
76
|
end
|
77
77
|
end
|
@@ -88,20 +88,20 @@ describe Appsignal::Hooks::Helpers do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should truncate the text to 200 chars max" do
|
91
|
-
with_helpers.truncate(very_long_text).
|
91
|
+
expect(with_helpers.truncate(very_long_text)).to eq "#{"a" * 197}..."
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
describe "#string_or_inspect" do
|
96
96
|
context "when string" do
|
97
97
|
it "should return the string" do
|
98
|
-
with_helpers.string_or_inspect("foo").
|
98
|
+
expect(with_helpers.string_or_inspect("foo")).to eq "foo"
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
context "when integer" do
|
103
103
|
it "should return the string" do
|
104
|
-
with_helpers.string_or_inspect(1).
|
104
|
+
expect(with_helpers.string_or_inspect(1)).to eq "1"
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -109,7 +109,7 @@ describe Appsignal::Hooks::Helpers do
|
|
109
109
|
let(:object) { Object.new }
|
110
110
|
|
111
111
|
it "should return the string" do
|
112
|
-
with_helpers.string_or_inspect(object).
|
112
|
+
expect(with_helpers.string_or_inspect(object)).to eq object.inspect
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -121,24 +121,24 @@ describe Appsignal::Hooks::Helpers do
|
|
121
121
|
context "when the key exists" do
|
122
122
|
subject { with_helpers.extract_value(hash, :key) }
|
123
123
|
|
124
|
-
it {
|
124
|
+
it { is_expected.to eq "value" }
|
125
125
|
end
|
126
126
|
|
127
127
|
context "when the key does not exist" do
|
128
128
|
subject { with_helpers.extract_value(hash, :nonexistent_key) }
|
129
129
|
|
130
|
-
it {
|
130
|
+
it { is_expected.to be_nil }
|
131
131
|
|
132
132
|
context "with a default value" do
|
133
133
|
subject { with_helpers.extract_value(hash, :nonexistent_key, 1) }
|
134
134
|
|
135
|
-
it {
|
135
|
+
it { is_expected.to eq 1 }
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
140
|
context "for a struct" do
|
141
|
-
before :
|
141
|
+
before :context do
|
142
142
|
TestStruct = Struct.new(:key)
|
143
143
|
end
|
144
144
|
let(:struct) { TestStruct.new("value") }
|
@@ -146,18 +146,18 @@ describe Appsignal::Hooks::Helpers do
|
|
146
146
|
context "when the key exists" do
|
147
147
|
subject { with_helpers.extract_value(struct, :key) }
|
148
148
|
|
149
|
-
it {
|
149
|
+
it { is_expected.to eq "value" }
|
150
150
|
end
|
151
151
|
|
152
152
|
context "when the key does not exist" do
|
153
153
|
subject { with_helpers.extract_value(struct, :nonexistent_key) }
|
154
154
|
|
155
|
-
it {
|
155
|
+
it { is_expected.to be_nil }
|
156
156
|
|
157
157
|
context "with a default value" do
|
158
158
|
subject { with_helpers.extract_value(struct, :nonexistent_key, 1) }
|
159
159
|
|
160
|
-
it {
|
160
|
+
it { is_expected.to eq 1 }
|
161
161
|
end
|
162
162
|
end
|
163
163
|
end
|
@@ -168,18 +168,18 @@ describe Appsignal::Hooks::Helpers do
|
|
168
168
|
context "when the method exists" do
|
169
169
|
subject { with_helpers.extract_value(object, :existing_method) }
|
170
170
|
|
171
|
-
it {
|
171
|
+
it { is_expected.to eq "value" }
|
172
172
|
end
|
173
173
|
|
174
174
|
context "when the method does not exist" do
|
175
175
|
subject { with_helpers.extract_value(object, :nonexistent_method) }
|
176
176
|
|
177
|
-
it {
|
177
|
+
it { is_expected.to be_nil }
|
178
178
|
|
179
179
|
context "and there is a default value" do
|
180
180
|
subject { with_helpers.extract_value(object, :nonexistent_method, 1) }
|
181
181
|
|
182
|
-
it {
|
182
|
+
it { is_expected.to eq 1 }
|
183
183
|
end
|
184
184
|
end
|
185
185
|
end
|
@@ -189,7 +189,7 @@ describe Appsignal::Hooks::Helpers do
|
|
189
189
|
|
190
190
|
subject { with_helpers.extract_value(object, :existing_method, nil, true) }
|
191
191
|
|
192
|
-
it {
|
192
|
+
it { is_expected.to eq "1" }
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
@@ -205,7 +205,7 @@ describe Appsignal::Hooks::Helpers do
|
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should format the arguments" do
|
208
|
-
with_helpers.format_args(args).
|
208
|
+
expect(with_helpers.format_args(args)).to eq([
|
209
209
|
"Model",
|
210
210
|
"1",
|
211
211
|
object.inspect,
|
@@ -25,7 +25,7 @@ describe Appsignal::Hooks::DataMapperLogListener do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
before { Appsignal::Transaction.
|
28
|
+
before { allow(Appsignal::Transaction).to receive(:current) { transaction } }
|
29
29
|
|
30
30
|
it "should record the log entry in an event" do
|
31
31
|
expect(transaction).to receive(:record_event).with(
|
@@ -27,7 +27,7 @@ if DependencyHelper.grape_present?
|
|
27
27
|
|
28
28
|
describe "#call" do
|
29
29
|
context "when AppSignal is not active" do
|
30
|
-
before(:
|
30
|
+
before(:context) do
|
31
31
|
Appsignal.config = nil
|
32
32
|
Appsignal::Hooks.load_hooks
|
33
33
|
end
|
@@ -45,9 +45,9 @@ if DependencyHelper.grape_present?
|
|
45
45
|
|
46
46
|
context "when AppSignal is active" do
|
47
47
|
let(:transaction) { http_request_transaction }
|
48
|
-
before :
|
48
|
+
before :context do
|
49
49
|
Appsignal.config = project_fixture_config
|
50
|
-
expect(Appsignal.active?).to
|
50
|
+
expect(Appsignal.active?).to be_truthy
|
51
51
|
end
|
52
52
|
before do
|
53
53
|
expect(Appsignal::Transaction).to receive(:create).with(
|
@@ -17,8 +17,8 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should sanitize command" do
|
20
|
-
Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter
|
21
|
-
.
|
20
|
+
expect(Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter)
|
21
|
+
.to receive(:format).with("find", "foo" => "bar")
|
22
22
|
|
23
23
|
subscriber.started(event)
|
24
24
|
end
|
@@ -26,11 +26,11 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
26
26
|
it "should store command on the transaction" do
|
27
27
|
subscriber.started(event)
|
28
28
|
|
29
|
-
transaction.store("mongo_driver").
|
29
|
+
expect(transaction.store("mongo_driver")).to eq(1 => { "foo" => "?" })
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should start an event in the extension" do
|
33
|
-
transaction.
|
33
|
+
expect(transaction).to receive(:start_event)
|
34
34
|
|
35
35
|
subscriber.started(event)
|
36
36
|
end
|
@@ -40,7 +40,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
40
40
|
let(:event) { double }
|
41
41
|
|
42
42
|
it "should finish the event" do
|
43
|
-
subscriber.
|
43
|
+
expect(subscriber).to receive(:finish).with("SUCCEEDED", event)
|
44
44
|
|
45
45
|
subscriber.succeeded(event)
|
46
46
|
end
|
@@ -50,7 +50,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
50
50
|
let(:event) { double }
|
51
51
|
|
52
52
|
it "should finish the event" do
|
53
|
-
subscriber.
|
53
|
+
expect(subscriber).to receive(:finish).with("FAILED", event)
|
54
54
|
|
55
55
|
subscriber.failed(event)
|
56
56
|
end
|
@@ -72,13 +72,13 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should get the query from the store" do
|
75
|
-
transaction.
|
75
|
+
expect(transaction).to receive(:store).with("mongo_driver").and_return(command)
|
76
76
|
|
77
77
|
subscriber.finish("SUCCEEDED", event)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should finish the transaction in the extension" do
|
81
|
-
transaction.
|
81
|
+
expect(transaction).to receive(:finish_event).with(
|
82
82
|
"query.mongodb",
|
83
83
|
"find | test | SUCCEEDED",
|
84
84
|
Appsignal::Utils.data_generate("foo" => "?"),
|
@@ -92,19 +92,17 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
92
92
|
|
93
93
|
context "without transaction" do
|
94
94
|
before do
|
95
|
-
Appsignal::Transaction.
|
96
|
-
:current => Appsignal::Transaction::NilTransaction.new
|
97
|
-
)
|
95
|
+
allow(Appsignal::Transaction).to receive(:current).and_return(Appsignal::Transaction::NilTransaction.new)
|
98
96
|
end
|
99
97
|
|
100
98
|
it "should not attempt to start an event" do
|
101
|
-
Appsignal::Extension.
|
99
|
+
expect(Appsignal::Extension).to_not receive(:start_event)
|
102
100
|
|
103
101
|
subscriber.started(double)
|
104
102
|
end
|
105
103
|
|
106
104
|
it "should not attempt to finish an event" do
|
107
|
-
Appsignal::Extension.
|
105
|
+
expect(Appsignal::Extension).to_not receive(:finish_event)
|
108
106
|
|
109
107
|
subscriber.finish("SUCCEEDED", double)
|
110
108
|
end
|
@@ -112,16 +110,16 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
112
110
|
|
113
111
|
context "when appsignal is paused" do
|
114
112
|
let(:transaction) { double(:paused? => true, :nil_transaction? => false) }
|
115
|
-
before { Appsignal::Transaction.
|
113
|
+
before { allow(Appsignal::Transaction).to receive(:current).and_return(transaction) }
|
116
114
|
|
117
115
|
it "should not attempt to start an event" do
|
118
|
-
Appsignal::Extension.
|
116
|
+
expect(Appsignal::Extension).to_not receive(:start_event)
|
119
117
|
|
120
118
|
subscriber.started(double)
|
121
119
|
end
|
122
120
|
|
123
121
|
it "should not attempt to finish an event" do
|
124
|
-
Appsignal::Extension.
|
122
|
+
expect(Appsignal::Extension).to_not receive(:finish_event)
|
125
123
|
|
126
124
|
subscriber.finish("SUCCEEDED", double)
|
127
125
|
end
|