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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -1
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +14 -15
  5. data/appsignal.gemspec +1 -1
  6. data/lib/appsignal.rb +1 -1
  7. data/lib/appsignal/auth_check.rb +5 -2
  8. data/lib/appsignal/cli/demo.rb +1 -1
  9. data/lib/appsignal/cli/diagnose.rb +1 -1
  10. data/lib/appsignal/cli/install.rb +1 -1
  11. data/lib/appsignal/transaction.rb +2 -1
  12. data/lib/appsignal/version.rb +1 -1
  13. data/spec/lib/appsignal/auth_check_spec.rb +9 -10
  14. data/spec/lib/appsignal/capistrano2_spec.rb +6 -6
  15. data/spec/lib/appsignal/capistrano3_spec.rb +6 -6
  16. data/spec/lib/appsignal/cli/demo_spec.rb +1 -1
  17. data/spec/lib/appsignal/cli/diagnose_spec.rb +1 -1
  18. data/spec/lib/appsignal/cli/helpers_spec.rb +2 -2
  19. data/spec/lib/appsignal/cli/install_spec.rb +2 -2
  20. data/spec/lib/appsignal/cli_spec.rb +2 -2
  21. data/spec/lib/appsignal/config_spec.rb +24 -24
  22. data/spec/lib/appsignal/demo_spec.rb +4 -2
  23. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +11 -7
  24. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +2 -2
  25. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +2 -2
  26. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +1 -1
  27. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +2 -2
  28. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +9 -9
  29. data/spec/lib/appsignal/event_formatter_spec.rb +17 -17
  30. data/spec/lib/appsignal/extension_spec.rb +7 -7
  31. data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +0 -3
  32. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +11 -3
  33. data/spec/lib/appsignal/hooks/celluloid_spec.rb +12 -4
  34. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +12 -4
  35. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +21 -13
  36. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +14 -6
  37. data/spec/lib/appsignal/hooks/net_http_spec.rb +11 -3
  38. data/spec/lib/appsignal/hooks/passenger_spec.rb +14 -6
  39. data/spec/lib/appsignal/hooks/puma_spec.rb +18 -10
  40. data/spec/lib/appsignal/hooks/rake_spec.rb +2 -2
  41. data/spec/lib/appsignal/hooks/redis_spec.rb +40 -30
  42. data/spec/lib/appsignal/hooks/sequel_spec.rb +11 -3
  43. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +15 -7
  44. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +17 -9
  45. data/spec/lib/appsignal/hooks/unicorn_spec.rb +16 -8
  46. data/spec/lib/appsignal/hooks/webmachine_spec.rb +14 -4
  47. data/spec/lib/appsignal/hooks_spec.rb +28 -28
  48. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +1 -1
  49. data/spec/lib/appsignal/integrations/grape_spec.rb +3 -3
  50. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +14 -16
  51. data/spec/lib/appsignal/integrations/object_spec.rb +10 -10
  52. data/spec/lib/appsignal/integrations/padrino_spec.rb +14 -18
  53. data/spec/lib/appsignal/integrations/railtie_spec.rb +35 -19
  54. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +2 -2
  55. data/spec/lib/appsignal/integrations/resque_spec.rb +8 -8
  56. data/spec/lib/appsignal/integrations/sinatra_spec.rb +2 -2
  57. data/spec/lib/appsignal/integrations/webmachine_spec.rb +1 -1
  58. data/spec/lib/appsignal/js_exception_transaction_spec.rb +1 -1
  59. data/spec/lib/appsignal/minutely_spec.rb +3 -3
  60. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +12 -12
  61. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +2 -2
  62. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +19 -15
  63. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +21 -21
  64. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +5 -5
  65. data/spec/lib/appsignal/system_spec.rb +5 -5
  66. data/spec/lib/appsignal/transaction_spec.rb +176 -155
  67. data/spec/lib/appsignal/transmitter_spec.rb +29 -23
  68. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +49 -35
  69. data/spec/lib/appsignal/utils_spec.rb +15 -8
  70. data/spec/lib/appsignal_spec.rb +134 -150
  71. data/spec/spec_helper.rb +5 -2
  72. metadata +6 -10
  73. data/spec/lib/tmp/config/appsignal.yml +0 -2
  74. data/spec/support/delegate_matcher.rb +0 -38
@@ -1,6 +1,6 @@
1
1
  describe Appsignal::Hooks::DelayedJobHook do
2
2
  context "with delayed job" do
3
- before(:all) do
3
+ before(:context) do
4
4
  module Delayed
5
5
  class Plugin
6
6
  def self.callbacks
@@ -14,12 +14,16 @@ describe Appsignal::Hooks::DelayedJobHook do
14
14
  end
15
15
  end
16
16
  end
17
- after(:all) { Object.send(:remove_const, :Delayed) }
17
+ after(:context) { Object.send(:remove_const, :Delayed) }
18
18
  before do
19
19
  start_agent
20
20
  end
21
21
 
22
- its(:dependencies_present?) { should be_true }
22
+ describe "#dependencies_present?" do
23
+ subject { described_class.new.dependencies_present? }
24
+
25
+ it { is_expected.to be_truthy }
26
+ end
23
27
 
24
28
  # We haven't found a way to test the hooks, we'll have to do that manually
25
29
 
@@ -43,7 +47,7 @@ describe Appsignal::Hooks::DelayedJobHook do
43
47
 
44
48
  context "with a normal call" do
45
49
  it "should wrap in a transaction with the correct params" do
46
- Appsignal.should_receive(:monitor_transaction).with(
50
+ expect(Appsignal).to receive(:monitor_transaction).with(
47
51
  "perform_job.delayed_job",
48
52
  :class => "TestClass",
49
53
  :method => "perform",
@@ -78,7 +82,7 @@ describe Appsignal::Hooks::DelayedJobHook do
78
82
  }
79
83
  end
80
84
  it "should wrap in a transaction with the correct params" do
81
- Appsignal.should_receive(:monitor_transaction).with(
85
+ expect(Appsignal).to receive(:monitor_transaction).with(
82
86
  "perform_job.delayed_job",
83
87
  :class => "CustomClass",
84
88
  :method => "perform",
@@ -108,7 +112,7 @@ describe Appsignal::Hooks::DelayedJobHook do
108
112
  let(:job) { ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper.new(job_data) }
109
113
 
110
114
  it "should wrap in a transaction with the correct params" do
111
- Appsignal.should_receive(:monitor_transaction).with(
115
+ expect(Appsignal).to receive(:monitor_transaction).with(
112
116
  "perform_job.delayed_job",
113
117
  :class => "TestClass",
114
118
  :method => "perform",
@@ -132,24 +136,28 @@ describe Appsignal::Hooks::DelayedJobHook do
132
136
 
133
137
  context "with an erroring call" do
134
138
  it "should add the error to the transaction" do
135
- Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
136
- Appsignal::Transaction.should_receive(:complete_current!)
139
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_error).with(error)
140
+ expect(Appsignal::Transaction).to receive(:complete_current!)
137
141
 
138
- invoked_block.stub(:call).and_raise(error)
142
+ allow(invoked_block).to receive(:call).and_raise(error)
139
143
 
140
- lambda do
144
+ expect do
141
145
  plugin.invoke_with_instrumentation(job, invoked_block)
142
- end.should raise_error(StandardError)
146
+ end.to raise_error(StandardError)
143
147
  end
144
148
  end
145
149
  end
146
150
 
147
151
  it "should add the plugin" do
148
- ::Delayed::Worker.plugins.should include Appsignal::Hooks::DelayedJobPlugin
152
+ expect(::Delayed::Worker.plugins).to include Appsignal::Hooks::DelayedJobPlugin
149
153
  end
150
154
  end
151
155
 
152
156
  context "without delayed job" do
153
- its(:dependencies_present?) { should be_false }
157
+ describe "#dependencies_present?" do
158
+ subject { described_class.new.dependencies_present? }
159
+
160
+ it { is_expected.to be_falsy }
161
+ end
154
162
  end
155
163
  end
@@ -3,9 +3,9 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
3
3
 
4
4
  context "with mongo ruby driver" do
5
5
  let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
6
- before { Appsignal::Hooks::MongoMonitorSubscriber.stub(:new => subscriber) }
6
+ before { allow(Appsignal::Hooks::MongoMonitorSubscriber).to receive(:new).and_return(subscriber) }
7
7
 
8
- before(:all) do
8
+ before(:context) do
9
9
  module Mongo
10
10
  module Monitoring
11
11
  COMMAND = "command"
@@ -17,12 +17,16 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
17
17
  end
18
18
  end
19
19
  end
20
- after(:all) { Object.send(:remove_const, :Mongo) }
20
+ after(:context) { Object.send(:remove_const, :Mongo) }
21
21
 
22
- its(:dependencies_present?) { should be_true }
22
+ describe "#dependencies_present?" do
23
+ subject { described_class.new.dependencies_present? }
24
+
25
+ it { is_expected.to be_truthy }
26
+ end
23
27
 
24
28
  it "adds a subscriber to Mongo::Monitoring" do
25
- Mongo::Monitoring::Global.should receive(:subscribe)
29
+ expect(Mongo::Monitoring::Global).to receive(:subscribe)
26
30
  .with("command", subscriber)
27
31
  .at_least(:once)
28
32
 
@@ -31,6 +35,10 @@ describe Appsignal::Hooks::MongoRubyDriverHook do
31
35
  end
32
36
 
33
37
  context "without mongo ruby driver" do
34
- its(:dependencies_present?) { should be_false }
38
+ describe "#dependencies_present?" do
39
+ subject { described_class.new.dependencies_present? }
40
+
41
+ it { is_expected.to be_falsy }
42
+ end
35
43
  end
36
44
  end
@@ -1,10 +1,14 @@
1
1
  describe Appsignal::Hooks::NetHttpHook do
2
- before :all do
2
+ before :context do
3
3
  start_agent
4
4
  end
5
5
 
6
6
  context "with Net::HTTP instrumentation enabled" do
7
- its(:dependencies_present?) { should be_true }
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 instrument a http request" do
10
14
  Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
@@ -40,6 +44,10 @@ describe Appsignal::Hooks::NetHttpHook do
40
44
  before { Appsignal.config.config_hash[:instrument_net_http] = false }
41
45
  after { Appsignal.config.config_hash[:instrument_net_http] = true }
42
46
 
43
- its(:dependencies_present?) { should be_false }
47
+ describe "#dependencies_present?" do
48
+ subject { described_class.new.dependencies_present? }
49
+
50
+ it { is_expected.to be_falsy }
51
+ end
44
52
  end
45
53
  end
@@ -1,22 +1,30 @@
1
1
  describe Appsignal::Hooks::PassengerHook do
2
2
  context "with passenger" do
3
- before(:all) do
3
+ before(:context) do
4
4
  module PhusionPassenger
5
5
  end
6
6
  end
7
- after(:all) { Object.send(:remove_const, :PhusionPassenger) }
7
+ after(:context) { Object.send(:remove_const, :PhusionPassenger) }
8
8
 
9
- its(:dependencies_present?) { should be_true }
9
+ describe "#dependencies_present?" do
10
+ subject { described_class.new.dependencies_present? }
11
+
12
+ it { is_expected.to be_truthy }
13
+ end
10
14
 
11
15
  it "adds behavior to stopping_worker_process and starting_worker_process" do
12
- PhusionPassenger.should_receive(:on_event).with(:starting_worker_process)
13
- PhusionPassenger.should_receive(:on_event).with(:stopping_worker_process)
16
+ expect(PhusionPassenger).to receive(:on_event).with(:starting_worker_process)
17
+ expect(PhusionPassenger).to receive(:on_event).with(:stopping_worker_process)
14
18
 
15
19
  Appsignal::Hooks::PassengerHook.new.install
16
20
  end
17
21
  end
18
22
 
19
23
  context "without passenger" do
20
- its(:dependencies_present?) { should be_false }
24
+ describe "#dependencies_present?" do
25
+ subject { described_class.new.dependencies_present? }
26
+
27
+ it { is_expected.to be_falsy }
28
+ end
21
29
  end
22
30
  end
@@ -1,6 +1,6 @@
1
1
  describe Appsignal::Hooks::PumaHook do
2
2
  context "with puma" do
3
- before(:all) do
3
+ before(:context) do
4
4
  class Puma
5
5
  def self.cli_config
6
6
  @cli_config ||= CliConfig.new
@@ -20,9 +20,13 @@ describe Appsignal::Hooks::PumaHook do
20
20
  end
21
21
  end
22
22
  end
23
- after(:all) { Object.send(:remove_const, :Puma) }
23
+ after(:context) { Object.send(:remove_const, :Puma) }
24
24
 
25
- its(:dependencies_present?) { should be_true }
25
+ describe "#dependencies_present?" do
26
+ subject { described_class.new.dependencies_present? }
27
+
28
+ it { is_expected.to be_truthy }
29
+ end
26
30
 
27
31
  context "when installed" do
28
32
  before do
@@ -32,8 +36,8 @@ describe Appsignal::Hooks::PumaHook do
32
36
  it "adds behavior to Unicorn::Worker#close" do
33
37
  cluster = Puma::Cluster.new
34
38
 
35
- Appsignal.should_receive(:stop)
36
- cluster.should_receive(:stop_workers_without_appsignal)
39
+ expect(Appsignal).to receive(:stop)
40
+ expect(cluster).to receive(:stop_workers_without_appsignal)
37
41
 
38
42
  cluster.stop_workers
39
43
  end
@@ -47,8 +51,8 @@ describe Appsignal::Hooks::PumaHook do
47
51
  end
48
52
 
49
53
  it "should add a before shutdown worker callback" do
50
- Puma.cli_config.options[:before_worker_boot].first.should be_a(Proc)
51
- Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc)
54
+ expect(Puma.cli_config.options[:before_worker_boot].first).to be_a(Proc)
55
+ expect(Puma.cli_config.options[:before_worker_shutdown].first).to be_a(Proc)
52
56
  end
53
57
  end
54
58
 
@@ -60,13 +64,17 @@ describe Appsignal::Hooks::PumaHook do
60
64
  end
61
65
 
62
66
  it "should add a before shutdown worker callback" do
63
- Puma.cli_config.options[:before_worker_boot].first.should be_a(Proc)
64
- Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc)
67
+ expect(Puma.cli_config.options[:before_worker_boot].first).to be_a(Proc)
68
+ expect(Puma.cli_config.options[:before_worker_shutdown].first).to be_a(Proc)
65
69
  end
66
70
  end
67
71
  end
68
72
 
69
73
  context "without puma" do
70
- its(:dependencies_present?) { should be_false }
74
+ describe "#dependencies_present?" do
75
+ subject { described_class.new.dependencies_present? }
76
+
77
+ it { is_expected.to be_falsy }
78
+ end
71
79
  end
72
80
  end
@@ -2,9 +2,9 @@ require "rake"
2
2
 
3
3
  describe Appsignal::Hooks::RakeHook do
4
4
  let(:task) { Rake::Task.new("task:name", Rake::Application.new) }
5
- before(:all) do
5
+ before(:context) do
6
6
  Appsignal.config = project_fixture_config
7
- expect(Appsignal.active?).to be_true
7
+ expect(Appsignal.active?).to be_truthy
8
8
  Appsignal::Hooks.load_hooks
9
9
  end
10
10
 
@@ -1,55 +1,65 @@
1
1
  describe Appsignal::Hooks::RedisHook do
2
- before :all do
2
+ before :context do
3
3
  start_agent
4
4
  end
5
5
 
6
6
  context "with redis" do
7
- context "with redis" do
8
- before :all do
9
- class Redis
10
- class Client
11
- def process(_commands)
12
- 1
13
- end
7
+ before :context do
8
+ class Redis
9
+ class Client
10
+ def process(_commands)
11
+ 1
14
12
  end
15
- VERSION = "1.0"
16
13
  end
14
+ VERSION = "1.0"
17
15
  end
16
+ end
18
17
 
19
- context "and redis instrumentation enabled" do
20
- before :all do
21
- Appsignal.config.config_hash[:instrument_redis] = true
22
- Appsignal::Hooks::RedisHook.new.install
23
- end
24
- after(:all) { Object.send(:remove_const, :Redis) }
18
+ context "with instrumentation enabled" do
19
+ before :context do
20
+ Appsignal.config.config_hash[:instrument_redis] = true
21
+ Appsignal::Hooks::RedisHook.new.install
22
+ end
23
+ after(:context) { Object.send(:remove_const, :Redis) }
25
24
 
26
- its(:dependencies_present?) { should be_true }
25
+ describe "#dependencies_present?" do
26
+ subject { described_class.new.dependencies_present? }
27
27
 
28
- it "should instrument a redis call" do
29
- Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
30
- expect(Appsignal::Transaction.current).to receive(:start_event)
31
- .at_least(:once)
32
- expect(Appsignal::Transaction.current).to receive(:finish_event)
33
- .at_least(:once)
34
- .with("query.redis", nil, nil, 0)
28
+ it { is_expected.to be_truthy }
29
+ end
35
30
 
36
- client = Redis::Client.new
31
+ it "should instrument a redis call" do
32
+ Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
33
+ expect(Appsignal::Transaction.current).to receive(:start_event)
34
+ .at_least(:once)
35
+ expect(Appsignal::Transaction.current).to receive(:finish_event)
36
+ .at_least(:once)
37
+ .with("query.redis", nil, nil, 0)
37
38
 
38
- client.process([]).should eq 1
39
- end
39
+ client = Redis::Client.new
40
+
41
+ expect(client.process([])).to eq 1
40
42
  end
41
43
  end
42
44
 
43
- context "and redis instrumentation disabled" do
44
- before :all do
45
+ context "with instrumentation disabled" do
46
+ before :context do
45
47
  Appsignal.config.config_hash[:instrument_net_http] = false
46
48
  end
47
49
 
48
- its(:dependencies_present?) { should be_false }
50
+ describe "#dependencies_present?" do
51
+ subject { described_class.new.dependencies_present? }
52
+
53
+ it { is_expected.to be_falsy }
54
+ end
49
55
  end
50
56
  end
51
57
 
52
58
  context "without redis" do
53
- its(:dependencies_present?) { should be_false }
59
+ describe "#dependencies_present?" do
60
+ subject { described_class.new.dependencies_present? }
61
+
62
+ it { is_expected.to be_falsy }
63
+ end
54
64
  end
55
65
  end
@@ -2,11 +2,15 @@ describe Appsignal::Hooks::SequelHook do
2
2
  if DependencyHelper.sequel_present?
3
3
  let(:db) { Sequel.sqlite }
4
4
 
5
- before :all do
5
+ before :context do
6
6
  start_agent
7
7
  end
8
8
 
9
- its(:dependencies_present?) { should be_true }
9
+ describe "#dependencies_present?" do
10
+ subject { described_class.new.dependencies_present? }
11
+
12
+ it { is_expected.to be_truthy }
13
+ end
10
14
 
11
15
  context "with a transaction" do
12
16
  let(:transaction) { Appsignal::Transaction.current }
@@ -27,6 +31,10 @@ describe Appsignal::Hooks::SequelHook do
27
31
  end
28
32
  end
29
33
  else
30
- its(:dependencies_present?) { should be_false }
34
+ describe "#dependencies_present?" do
35
+ subject { described_class.new.dependencies_present? }
36
+
37
+ it { is_expected.to be_falsy }
38
+ end
31
39
  end
32
40
  end
@@ -7,7 +7,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
7
7
  let(:body) { {} }
8
8
 
9
9
  before do
10
- Appsignal::Transaction.stub(:current => current_transaction)
10
+ allow(Appsignal::Transaction).to receive(:current).and_return(current_transaction)
11
11
  start_agent
12
12
  end
13
13
 
@@ -24,7 +24,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
24
24
  end
25
25
 
26
26
  it "should wrap in a transaction with the correct params" do
27
- Appsignal.should_receive(:monitor_transaction).with(
27
+ expect(Appsignal).to receive(:monitor_transaction).with(
28
28
  "perform_job.shoryuken",
29
29
  :class => "TestClass",
30
30
  :method => "perform",
@@ -50,7 +50,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
50
50
  let(:error) { VerySpecificError.new }
51
51
 
52
52
  it "should add the exception to appsignal" do
53
- Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
53
+ expect_any_instance_of(Appsignal::Transaction).to receive(:set_error).with(error)
54
54
  end
55
55
 
56
56
  after do
@@ -68,7 +68,7 @@ end
68
68
 
69
69
  describe Appsignal::Hooks::ShoryukenHook do
70
70
  context "with shoryuken" do
71
- before(:all) do
71
+ before(:context) do
72
72
  module Shoryuken
73
73
  def self.configure_server
74
74
  end
@@ -76,14 +76,22 @@ describe Appsignal::Hooks::ShoryukenHook do
76
76
  Appsignal::Hooks::ShoryukenHook.new.install
77
77
  end
78
78
 
79
- after(:all) do
79
+ after(:context) do
80
80
  Object.send(:remove_const, :Shoryuken)
81
81
  end
82
82
 
83
- its(:dependencies_present?) { should be_true }
83
+ describe "#dependencies_present?" do
84
+ subject { described_class.new.dependencies_present? }
85
+
86
+ it { is_expected.to be_truthy }
87
+ end
84
88
  end
85
89
 
86
90
  context "without shoryuken" do
87
- its(:dependencies_present?) { should be_false }
91
+ describe "#dependencies_present?" do
92
+ subject { described_class.new.dependencies_present? }
93
+
94
+ it { is_expected.to be_falsy }
95
+ end
88
96
  end
89
97
  end