appsignal 2.1.0.alpha.3 → 2.1.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +43 -0
- data/.rubocop_todo.yml +289 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +11 -1
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/appsignal.gemspec +1 -0
- data/bin/appsignal +2 -2
- data/ext/agent.yml +11 -11
- data/ext/extconf.rb +33 -33
- data/gemfiles/rails-4.2.gemfile +4 -0
- data/gemfiles/resque.gemfile +4 -0
- data/lib/appsignal.rb +58 -54
- data/lib/appsignal/auth_check.rb +15 -16
- data/lib/appsignal/capistrano.rb +4 -4
- data/lib/appsignal/cli.rb +28 -28
- data/lib/appsignal/cli/diagnose.rb +11 -11
- data/lib/appsignal/cli/helpers.rb +1 -1
- data/lib/appsignal/cli/install.rb +38 -38
- data/lib/appsignal/cli/notify_of_deploy.rb +1 -1
- data/lib/appsignal/config.rb +73 -71
- data/lib/appsignal/event_formatter.rb +8 -8
- data/lib/appsignal/event_formatter/action_view/render_formatter.rb +4 -4
- data/lib/appsignal/event_formatter/active_record/instantiation_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/elastic_search/search_formatter.rb +9 -7
- data/lib/appsignal/event_formatter/faraday/request_formatter.rb +1 -1
- data/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb +6 -6
- data/lib/appsignal/event_formatter/moped/query_formatter.rb +56 -43
- data/lib/appsignal/extension.rb +5 -5
- data/lib/appsignal/hooks.rb +28 -26
- data/lib/appsignal/hooks/active_support_notifications.rb +2 -2
- data/lib/appsignal/hooks/celluloid.rb +1 -1
- data/lib/appsignal/hooks/data_mapper.rb +2 -2
- data/lib/appsignal/hooks/delayed_job.rb +1 -1
- data/lib/appsignal/hooks/mongo_ruby_driver.rb +1 -1
- data/lib/appsignal/hooks/net_http.rb +4 -4
- data/lib/appsignal/hooks/passenger.rb +2 -2
- data/lib/appsignal/hooks/puma.rb +4 -4
- data/lib/appsignal/hooks/rake.rb +1 -1
- data/lib/appsignal/hooks/redis.rb +1 -1
- data/lib/appsignal/hooks/sequel.rb +2 -2
- data/lib/appsignal/hooks/shoryuken.rb +8 -8
- data/lib/appsignal/hooks/sidekiq.rb +16 -15
- data/lib/appsignal/hooks/unicorn.rb +1 -1
- data/lib/appsignal/hooks/webmachine.rb +1 -1
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +6 -6
- data/lib/appsignal/integrations/data_mapper.rb +2 -3
- data/lib/appsignal/integrations/delayed_job_plugin.rb +5 -5
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +6 -6
- data/lib/appsignal/integrations/padrino.rb +8 -8
- data/lib/appsignal/integrations/railtie.rb +5 -5
- data/lib/appsignal/integrations/resque.rb +4 -5
- data/lib/appsignal/integrations/resque_active_job.rb +3 -6
- data/lib/appsignal/integrations/sinatra.rb +2 -2
- data/lib/appsignal/integrations/webmachine.rb +2 -3
- data/lib/appsignal/js_exception_transaction.rb +10 -10
- data/lib/appsignal/marker.rb +3 -3
- data/lib/appsignal/rack/generic_instrumentation.rb +10 -9
- data/lib/appsignal/rack/js_exception_catcher.rb +7 -6
- data/lib/appsignal/rack/rails_instrumentation.rb +9 -8
- data/lib/appsignal/rack/sinatra_instrumentation.rb +19 -17
- data/lib/appsignal/rack/streaming_listener.rb +9 -8
- data/lib/appsignal/system.rb +19 -17
- data/lib/appsignal/transaction.rb +97 -40
- data/lib/appsignal/transmitter.rb +23 -30
- data/lib/appsignal/utils.rb +3 -3
- data/lib/appsignal/utils/params_sanitizer.rb +1 -1
- data/lib/appsignal/utils/query_params_sanitizer.rb +1 -1
- data/lib/appsignal/version.rb +2 -2
- data/spec/.rubocop.yml +4 -0
- data/spec/lib/appsignal/auth_check_spec.rb +7 -7
- data/spec/lib/appsignal/capistrano2_spec.rb +41 -41
- data/spec/lib/appsignal/capistrano3_spec.rb +43 -44
- data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +9 -11
- data/spec/lib/appsignal/cli_spec.rb +9 -9
- data/spec/lib/appsignal/config_spec.rb +88 -86
- data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +9 -9
- data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +12 -12
- data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +4 -4
- data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +23 -23
- data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +29 -30
- data/spec/lib/appsignal/event_formatter_spec.rb +28 -28
- data/spec/lib/appsignal/extension_spec.rb +15 -15
- data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +6 -5
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +12 -12
- data/spec/lib/appsignal/hooks/delayed_job_spec.rb +34 -34
- data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/net_http_spec.rb +10 -10
- data/spec/lib/appsignal/hooks/rake_spec.rb +7 -7
- data/spec/lib/appsignal/hooks/redis_spec.rb +6 -6
- data/spec/lib/appsignal/hooks/shoryuken_spec.rb +21 -22
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +48 -45
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +2 -2
- data/spec/lib/appsignal/hooks_spec.rb +16 -17
- data/spec/lib/appsignal/integrations/data_mapper_spec.rb +7 -8
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +19 -19
- data/spec/lib/appsignal/integrations/object_spec.rb +3 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +44 -44
- data/spec/lib/appsignal/integrations/railtie_spec.rb +13 -13
- data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +7 -7
- data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +7 -7
- data/spec/lib/appsignal/integrations/webmachine_spec.rb +15 -15
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +23 -23
- data/spec/lib/appsignal/marker_spec.rb +8 -8
- data/spec/lib/appsignal/minutely_spec.rb +6 -6
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +7 -7
- data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +13 -13
- data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +11 -11
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
- data/spec/lib/appsignal/rack/streaming_listener_spec.rb +36 -36
- data/spec/lib/appsignal/system/container_spec.rb +1 -1
- data/spec/lib/appsignal/transaction_spec.rb +213 -184
- data/spec/lib/appsignal/transmitter_spec.rb +20 -20
- data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +19 -19
- data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +41 -41
- data/spec/lib/appsignal/utils_spec.rb +41 -37
- data/spec/lib/appsignal_spec.rb +150 -142
- data/spec/spec_helper.rb +18 -18
- data/spec/support/delegate_matcher.rb +6 -6
- data/spec/support/helpers/api_request_helper.rb +2 -2
- data/spec/support/helpers/config_helpers.rb +3 -3
- data/spec/support/helpers/dependency_helper.rb +13 -13
- data/spec/support/helpers/directory_helper.rb +5 -5
- data/spec/support/helpers/env_helpers.rb +14 -14
- data/spec/support/helpers/system_helpers.rb +3 -3
- data/spec/support/helpers/transaction_helpers.rb +10 -10
- metadata +20 -2
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require "fileutils"
|
2
2
|
|
3
3
|
describe "extension loading and operation" do
|
4
4
|
describe ".agent_config" do
|
5
5
|
subject { Appsignal::Extension.agent_config }
|
6
6
|
|
7
|
-
it { should have_key(
|
8
|
-
it { should have_key(
|
7
|
+
it { should have_key("version") }
|
8
|
+
it { should have_key("triples") }
|
9
9
|
end
|
10
10
|
|
11
11
|
describe ".agent_version" do
|
@@ -37,30 +37,30 @@ describe "extension loading and operation" do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context "with a transaction" do
|
40
|
-
subject { Appsignal::Extension.start_transaction(
|
40
|
+
subject { Appsignal::Extension.start_transaction("request_id", "http_request", 0) }
|
41
41
|
|
42
42
|
it "should have a start_event method" do
|
43
43
|
subject.start_event(0)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should have a finish_event method" do
|
47
|
-
subject.finish_event(
|
47
|
+
subject.finish_event("name", "title", "body", 0, 0)
|
48
48
|
end
|
49
49
|
|
50
50
|
it "should have a record_event method" do
|
51
|
-
subject.record_event(
|
51
|
+
subject.record_event("name", "title", "body", 1000, 0, 1000)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should have a set_error method" do
|
55
|
-
subject.set_error(
|
55
|
+
subject.set_error("name", "message", Appsignal::Extension.data_map_new)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should have a set_sample_data method" do
|
59
|
-
subject.set_sample_data(
|
59
|
+
subject.set_sample_data("params", Appsignal::Extension.data_map_new)
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should have a set_action method" do
|
63
|
-
subject.set_action(
|
63
|
+
subject.set_action("value")
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should have a set_queue_start method" do
|
@@ -68,7 +68,7 @@ describe "extension loading and operation" do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should have a set_metadata method" do
|
71
|
-
subject.set_metadata(
|
71
|
+
subject.set_metadata("key", "value")
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should have a finish method" do
|
@@ -81,15 +81,15 @@ describe "extension loading and operation" do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should have a set_gauge method" do
|
84
|
-
subject.set_gauge(
|
84
|
+
subject.set_gauge("key", 1.0)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should have a increment_counter method" do
|
88
|
-
subject.increment_counter(
|
88
|
+
subject.increment_counter("key", 1)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should have a add_distribution_value method" do
|
92
|
-
subject.add_distribution_value(
|
92
|
+
subject.add_distribution_value("key", 1.0)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
@@ -109,9 +109,9 @@ describe "extension loading and operation" do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should not raise errors when methods are called" do
|
112
|
-
expect
|
112
|
+
expect do
|
113
113
|
subject.something
|
114
|
-
|
114
|
+
end.not_to raise_error
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require_relative
|
1
|
+
require "spec_helper"
|
2
|
+
require_relative "../../support/mocks/fake_gc_profiler"
|
3
3
|
|
4
4
|
describe Appsignal::GarbageCollectionProfiler do
|
5
5
|
let(:internal_profiler) { FakeGCProfiler.new }
|
@@ -33,8 +33,8 @@ describe Appsignal::GarbageCollectionProfiler do
|
|
33
33
|
describe "when the total GC time becomes too high" do
|
34
34
|
it "should reset" do
|
35
35
|
profiler = Appsignal::GarbageCollectionProfiler.new
|
36
|
-
|
37
|
-
|
36
|
+
internal_profiler.total_time = 2_147_483_647
|
37
|
+
expect(profiler.total_time).to eq(0)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -53,7 +53,8 @@ describe Appsignal::GarbageCollectionProfiler do
|
|
53
53
|
|
54
54
|
describe "in multiple threads, with a slow GC::Profiler" do
|
55
55
|
it "should not count garbage collection times twice" do
|
56
|
-
threads
|
56
|
+
threads = []
|
57
|
+
results = []
|
57
58
|
internal_profiler.clear_delay = 0.001
|
58
59
|
internal_profiler.total_time = 0.12345
|
59
60
|
|
@@ -4,7 +4,7 @@ describe Appsignal::Hooks::ActiveSupportNotificationsHook do
|
|
4
4
|
start_agent
|
5
5
|
end
|
6
6
|
before do
|
7
|
-
Appsignal::Transaction.create(
|
7
|
+
Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:notifier) { ActiveSupport::Notifications::Fanout.new }
|
@@ -13,28 +13,28 @@ describe Appsignal::Hooks::ActiveSupportNotificationsHook do
|
|
13
13
|
its(:dependencies_present?) { should be_true }
|
14
14
|
|
15
15
|
it "should instrument an AS notifications instrument call with a block" do
|
16
|
-
expect(
|
16
|
+
expect(Appsignal::Transaction.current).to receive(:start_event)
|
17
17
|
.at_least(:once)
|
18
|
-
expect(
|
18
|
+
expect(Appsignal::Transaction.current).to receive(:finish_event)
|
19
19
|
.at_least(:once)
|
20
|
-
.with("sql.active_record", nil,
|
20
|
+
.with("sql.active_record", nil, "SQL", 1)
|
21
21
|
|
22
|
-
return_value = instrumenter.instrument(
|
23
|
-
|
22
|
+
return_value = instrumenter.instrument("sql.active_record", :sql => "SQL") do
|
23
|
+
"value"
|
24
24
|
end
|
25
25
|
|
26
|
-
expect(return_value).to eq
|
26
|
+
expect(return_value).to eq "value"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should not instrument events whose name starts with a bang" do
|
30
|
-
expect(
|
31
|
-
expect(
|
30
|
+
expect(Appsignal::Transaction.current).not_to receive(:start_event)
|
31
|
+
expect(Appsignal::Transaction.current).not_to receive(:finish_event)
|
32
32
|
|
33
|
-
return_value = instrumenter.instrument(
|
34
|
-
|
33
|
+
return_value = instrumenter.instrument("!sql.active_record", :sql => "SQL") do
|
34
|
+
"value"
|
35
35
|
end
|
36
36
|
|
37
|
-
expect(return_value).to eq
|
37
|
+
expect(return_value).to eq "value"
|
38
38
|
end
|
39
39
|
else
|
40
40
|
its(:dependencies_present?) { should be_false }
|
@@ -25,36 +25,36 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
25
25
|
|
26
26
|
describe ".invoke_with_instrumentation" do
|
27
27
|
let(:plugin) { Appsignal::Hooks::DelayedJobPlugin }
|
28
|
-
let(:time) { Time.parse(
|
28
|
+
let(:time) { Time.parse("01-01-2001 10:01:00UTC") }
|
29
29
|
let(:job_data) do
|
30
30
|
{
|
31
31
|
:id => 123,
|
32
|
-
:name =>
|
32
|
+
:name => "TestClass#perform",
|
33
33
|
:priority => 1,
|
34
34
|
:attempts => 1,
|
35
|
-
:queue =>
|
35
|
+
:queue => "default",
|
36
36
|
:created_at => time - 60_000,
|
37
|
-
:payload_object => double(:args => [
|
37
|
+
:payload_object => double(:args => ["argument"])
|
38
38
|
}
|
39
39
|
end
|
40
40
|
let(:job) { double(job_data) }
|
41
|
-
let(:invoked_block) {
|
41
|
+
let(:invoked_block) { proc {} }
|
42
42
|
let(:error) { StandardError.new }
|
43
43
|
|
44
44
|
context "with a normal call" do
|
45
45
|
it "should wrap in a transaction with the correct params" do
|
46
46
|
Appsignal.should_receive(:monitor_transaction).with(
|
47
|
-
|
48
|
-
:class =>
|
49
|
-
:method =>
|
47
|
+
"perform_job.delayed_job",
|
48
|
+
:class => "TestClass",
|
49
|
+
:method => "perform",
|
50
50
|
:metadata => {
|
51
51
|
:priority => 1,
|
52
52
|
:attempts => 1,
|
53
|
-
:queue =>
|
54
|
-
:id =>
|
53
|
+
:queue => "default",
|
54
|
+
:id => "123"
|
55
55
|
},
|
56
|
-
:params => [
|
57
|
-
:queue_start => time - 60_000
|
56
|
+
:params => ["argument"],
|
57
|
+
:queue_start => time - 60_000
|
58
58
|
)
|
59
59
|
|
60
60
|
Timecop.freeze(time) do
|
@@ -66,29 +66,29 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
66
66
|
let(:job_data) do
|
67
67
|
{
|
68
68
|
:payload_object => double(
|
69
|
-
:appsignal_name =>
|
70
|
-
:args => [
|
69
|
+
:appsignal_name => "CustomClass#perform",
|
70
|
+
:args => ["argument"]
|
71
71
|
),
|
72
|
-
:id =>
|
73
|
-
:name =>
|
72
|
+
:id => "123",
|
73
|
+
:name => "TestClass#perform",
|
74
74
|
:priority => 1,
|
75
75
|
:attempts => 1,
|
76
|
-
:queue =>
|
76
|
+
:queue => "default",
|
77
77
|
:created_at => time - 60_000
|
78
78
|
}
|
79
79
|
end
|
80
80
|
it "should wrap in a transaction with the correct params" do
|
81
81
|
Appsignal.should_receive(:monitor_transaction).with(
|
82
|
-
|
83
|
-
:class =>
|
84
|
-
:method =>
|
82
|
+
"perform_job.delayed_job",
|
83
|
+
:class => "CustomClass",
|
84
|
+
:method => "perform",
|
85
85
|
:metadata => {
|
86
86
|
:priority => 1,
|
87
87
|
:attempts => 1,
|
88
|
-
:queue =>
|
89
|
-
:id =>
|
88
|
+
:queue => "default",
|
89
|
+
:id => "123"
|
90
90
|
},
|
91
|
-
:params => [
|
91
|
+
:params => ["argument"],
|
92
92
|
:queue_start => time - 60_000
|
93
93
|
)
|
94
94
|
|
@@ -99,27 +99,27 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
99
99
|
end
|
100
100
|
|
101
101
|
if active_job_present?
|
102
|
-
require
|
102
|
+
require "active_job"
|
103
103
|
|
104
104
|
context "when wrapped by ActiveJob" do
|
105
105
|
before do
|
106
|
-
job_data[:args] = [
|
106
|
+
job_data[:args] = ["argument"]
|
107
107
|
end
|
108
108
|
let(:job) { ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper.new(job_data) }
|
109
109
|
|
110
110
|
it "should wrap in a transaction with the correct params" do
|
111
111
|
Appsignal.should_receive(:monitor_transaction).with(
|
112
|
-
|
113
|
-
:class =>
|
114
|
-
:method =>
|
112
|
+
"perform_job.delayed_job",
|
113
|
+
:class => "TestClass",
|
114
|
+
:method => "perform",
|
115
115
|
:metadata => {
|
116
116
|
:priority => 1,
|
117
117
|
:attempts => 1,
|
118
|
-
:queue =>
|
119
|
-
:id =>
|
118
|
+
:queue => "default",
|
119
|
+
:id => "123"
|
120
120
|
},
|
121
|
-
:params => [
|
122
|
-
:queue_start => time - 60_000
|
121
|
+
:params => ["argument"],
|
122
|
+
:queue_start => time - 60_000
|
123
123
|
)
|
124
124
|
|
125
125
|
Timecop.freeze(time) do
|
@@ -137,9 +137,9 @@ describe Appsignal::Hooks::DelayedJobHook do
|
|
137
137
|
|
138
138
|
invoked_block.stub(:call).and_raise(error)
|
139
139
|
|
140
|
-
lambda
|
140
|
+
lambda do
|
141
141
|
plugin.invoke_with_instrumentation(job, invoked_block)
|
142
|
-
|
142
|
+
end.should raise_error(StandardError)
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Appsignal::Hooks::MongoRubyDriverHook do
|
2
|
-
require
|
2
|
+
require "appsignal/integrations/mongo_ruby_driver"
|
3
3
|
|
4
4
|
context "with mongo ruby driver" do
|
5
5
|
let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
|
@@ -8,7 +8,7 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
|
|
8
8
|
before(:all) do
|
9
9
|
module Mongo
|
10
10
|
module Monitoring
|
11
|
-
COMMAND =
|
11
|
+
COMMAND = "command"
|
12
12
|
|
13
13
|
class Global
|
14
14
|
def subscribe
|
@@ -23,7 +23,7 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
|
|
23
23
|
|
24
24
|
it "adds a subscriber to Mongo::Monitoring" do
|
25
25
|
Mongo::Monitoring::Global.should receive(:subscribe)
|
26
|
-
.with(
|
26
|
+
.with("command", subscriber)
|
27
27
|
.at_least(:once)
|
28
28
|
|
29
29
|
Appsignal::Hooks::MongoRubyDriverHook.new.install
|
@@ -7,29 +7,29 @@ describe Appsignal::Hooks::NetHttpHook do
|
|
7
7
|
its(:dependencies_present?) { should be_true }
|
8
8
|
|
9
9
|
it "should instrument a http request" do
|
10
|
-
Appsignal::Transaction.create(
|
11
|
-
expect(
|
10
|
+
Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
|
11
|
+
expect(Appsignal::Transaction.current).to receive(:start_event)
|
12
12
|
.at_least(:once)
|
13
|
-
expect(
|
13
|
+
expect(Appsignal::Transaction.current).to receive(:finish_event)
|
14
14
|
.at_least(:once)
|
15
15
|
.with("request.net_http", "GET http://www.google.com", nil, 0)
|
16
16
|
|
17
|
-
stub_request(:any,
|
17
|
+
stub_request(:any, "http://www.google.com/")
|
18
18
|
|
19
|
-
Net::HTTP.get_response(URI.parse(
|
19
|
+
Net::HTTP.get_response(URI.parse("http://www.google.com"))
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should instrument a https request" do
|
23
|
-
Appsignal::Transaction.create(
|
24
|
-
expect(
|
23
|
+
Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
|
24
|
+
expect(Appsignal::Transaction.current).to receive(:start_event)
|
25
25
|
.at_least(:once)
|
26
|
-
expect(
|
26
|
+
expect(Appsignal::Transaction.current).to receive(:finish_event)
|
27
27
|
.at_least(:once)
|
28
28
|
.with("request.net_http", "GET https://www.google.com", nil, 0)
|
29
29
|
|
30
|
-
stub_request(:any,
|
30
|
+
stub_request(:any, "https://www.google.com/")
|
31
31
|
|
32
|
-
uri = URI.parse(
|
32
|
+
uri = URI.parse("https://www.google.com")
|
33
33
|
http = Net::HTTP.new(uri.host, uri.port)
|
34
34
|
http.use_ssl = true
|
35
35
|
http.get(uri.request_uri)
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "rake"
|
2
2
|
|
3
3
|
describe Appsignal::Hooks::RakeHook do
|
4
|
-
let(:task) { Rake::Task.new(
|
4
|
+
let(:task) { Rake::Task.new("task:name", Rake::Application.new) }
|
5
5
|
before(:all) do
|
6
6
|
Appsignal.config = project_fixture_config
|
7
7
|
expect(Appsignal.active?).to be_true
|
@@ -15,10 +15,10 @@ describe Appsignal::Hooks::RakeHook do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "calls the original task" do
|
18
|
-
expect(task).to receive(:execute_without_appsignal).with(
|
18
|
+
expect(task).to receive(:execute_without_appsignal).with("foo")
|
19
19
|
end
|
20
20
|
|
21
|
-
after { task.execute(
|
21
|
+
after { task.execute("foo") }
|
22
22
|
end
|
23
23
|
|
24
24
|
context "with error" do
|
@@ -35,7 +35,7 @@ describe Appsignal::Hooks::RakeHook do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "sets the action" do
|
38
|
-
expect(transaction).to receive(:set_action).with(
|
38
|
+
expect(transaction).to receive(:set_action).with("task:name")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "sets the error" do
|
@@ -44,11 +44,11 @@ describe Appsignal::Hooks::RakeHook do
|
|
44
44
|
|
45
45
|
it "completes the transaction and stops" do
|
46
46
|
expect(transaction).to receive(:complete).ordered
|
47
|
-
expect(Appsignal).to receive(:stop).with(
|
47
|
+
expect(Appsignal).to receive(:stop).with("rake").ordered
|
48
48
|
end
|
49
49
|
|
50
50
|
after do
|
51
|
-
expect { task.execute(
|
51
|
+
expect { task.execute("foo") }.to raise_error VerySpecificError
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -8,11 +8,11 @@ describe Appsignal::Hooks::RedisHook do
|
|
8
8
|
before :all do
|
9
9
|
class Redis
|
10
10
|
class Client
|
11
|
-
def process(
|
11
|
+
def process(_commands)
|
12
12
|
1
|
13
13
|
end
|
14
14
|
end
|
15
|
-
VERSION =
|
15
|
+
VERSION = "1.0"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -26,12 +26,12 @@ describe Appsignal::Hooks::RedisHook do
|
|
26
26
|
its(:dependencies_present?) { should be_true }
|
27
27
|
|
28
28
|
it "should instrument a redis call" do
|
29
|
-
Appsignal::Transaction.create(
|
30
|
-
expect(
|
29
|
+
Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
|
30
|
+
expect(Appsignal::Transaction.current).to receive(:start_event)
|
31
31
|
.at_least(:once)
|
32
|
-
expect(
|
32
|
+
expect(Appsignal::Transaction.current).to receive(:finish_event)
|
33
33
|
.at_least(:once)
|
34
|
-
.with(
|
34
|
+
.with("query.redis", nil, nil, 0)
|
35
35
|
|
36
36
|
client = Redis::Client.new
|
37
37
|
|
@@ -3,43 +3,42 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
|
|
3
3
|
|
4
4
|
let(:worker_instance) { double }
|
5
5
|
let(:queue) { double }
|
6
|
-
let(:sqs_msg) {
|
7
|
-
|
8
|
-
}
|
9
|
-
let(:body) {{}}
|
6
|
+
let(:sqs_msg) { double(:attributes => {}) }
|
7
|
+
let(:body) { {} }
|
10
8
|
|
11
9
|
before do
|
12
|
-
Appsignal.stub(:is_ignored_exception? => false)
|
13
10
|
Appsignal::Transaction.stub(:current => current_transaction)
|
14
11
|
start_agent
|
15
12
|
end
|
16
13
|
|
17
14
|
context "with a performance call" do
|
18
|
-
let(:queue) {
|
19
|
-
let(:sqs_msg)
|
20
|
-
double(:attributes => {
|
21
|
-
|
22
|
-
let(:body)
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
let(:queue) { "some-funky-queue-name" }
|
16
|
+
let(:sqs_msg) do
|
17
|
+
double(:attributes => { "SentTimestamp" => Time.parse("1976-11-18 0:00:00UTC").to_i * 1000 })
|
18
|
+
end
|
19
|
+
let(:body) do
|
20
|
+
{
|
21
|
+
"job_class" => "TestClass",
|
22
|
+
"arguments" => ["Model", "1"]
|
23
|
+
}
|
24
|
+
end
|
26
25
|
|
27
26
|
it "should wrap in a transaction with the correct params" do
|
28
27
|
Appsignal.should_receive(:monitor_transaction).with(
|
29
|
-
|
30
|
-
:class =>
|
31
|
-
:method =>
|
28
|
+
"perform_job.shoryuken",
|
29
|
+
:class => "TestClass",
|
30
|
+
:method => "perform",
|
32
31
|
:metadata => {
|
33
|
-
:queue =>
|
34
|
-
|
32
|
+
:queue => "some-funky-queue-name",
|
33
|
+
"SentTimestamp" => 217_123_200_000
|
35
34
|
},
|
36
|
-
:params => [
|
37
|
-
:queue_start => Time.parse(
|
35
|
+
:params => ["Model", "1"],
|
36
|
+
:queue_start => Time.parse("1976-11-18 0:00:00UTC").utc
|
38
37
|
)
|
39
38
|
end
|
40
39
|
|
41
40
|
after do
|
42
|
-
Timecop.freeze(Time.parse(
|
41
|
+
Timecop.freeze(Time.parse("01-01-2001 10:01:00UTC")) do
|
43
42
|
Appsignal::Hooks::ShoryukenMiddleware.new.call(worker_instance, queue, sqs_msg, body) do
|
44
43
|
# nothing
|
45
44
|
end
|
@@ -56,7 +55,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
|
|
56
55
|
|
57
56
|
after do
|
58
57
|
begin
|
59
|
-
Timecop.freeze(Time.parse(
|
58
|
+
Timecop.freeze(Time.parse("01-01-2001 10:01:00UTC")) do
|
60
59
|
Appsignal::Hooks::ShoryukenMiddleware.new.call(worker_instance, queue, sqs_msg, body) do
|
61
60
|
raise error
|
62
61
|
end
|