appsignal 1.4.0.alpha.2 → 1.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -1
  3. data/.travis.yml +3 -1
  4. data/CHANGELOG.md +38 -1
  5. data/Rakefile +29 -12
  6. data/benchmark.rake +3 -7
  7. data/ext/agent.yml +11 -11
  8. data/ext/appsignal_extension.c +364 -72
  9. data/ext/extconf.rb +2 -4
  10. data/gemfiles/resque.gemfile +1 -0
  11. data/lib/appsignal.rb +40 -30
  12. data/lib/appsignal/auth_check.rb +1 -1
  13. data/lib/appsignal/cli/diagnose.rb +4 -3
  14. data/lib/appsignal/cli/install.rb +16 -15
  15. data/lib/appsignal/config.rb +31 -31
  16. data/lib/appsignal/event_formatter.rb +1 -1
  17. data/lib/appsignal/extension.rb +6 -0
  18. data/lib/appsignal/garbage_collection_profiler.rb +47 -0
  19. data/lib/appsignal/hooks.rb +1 -0
  20. data/lib/appsignal/hooks/active_support_notifications.rb +43 -0
  21. data/lib/appsignal/integrations/capistrano/appsignal.cap +1 -1
  22. data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +2 -2
  23. data/lib/appsignal/integrations/mongo_ruby_driver.rb +1 -1
  24. data/lib/appsignal/integrations/object.rb +4 -4
  25. data/lib/appsignal/integrations/padrino.rb +1 -1
  26. data/lib/appsignal/integrations/sinatra.rb +1 -1
  27. data/lib/appsignal/integrations/webmachine.rb +2 -2
  28. data/lib/appsignal/js_exception_transaction.rb +7 -10
  29. data/lib/appsignal/marker.rb +3 -2
  30. data/lib/appsignal/rack/generic_instrumentation.rb +1 -1
  31. data/lib/appsignal/rack/sinatra_instrumentation.rb +13 -6
  32. data/lib/appsignal/rack/streaming_listener.rb +5 -3
  33. data/lib/appsignal/system.rb +36 -0
  34. data/lib/appsignal/transaction.rb +20 -20
  35. data/lib/appsignal/transmitter.rb +11 -7
  36. data/lib/appsignal/utils.rb +76 -2
  37. data/lib/appsignal/version.rb +1 -1
  38. data/spec/lib/appsignal/auth_check_spec.rb +0 -2
  39. data/spec/lib/appsignal/capistrano2_spec.rb +99 -79
  40. data/spec/lib/appsignal/capistrano3_spec.rb +57 -78
  41. data/spec/lib/appsignal/cli/diagnose_spec.rb +17 -15
  42. data/spec/lib/appsignal/cli/install_spec.rb +38 -20
  43. data/spec/lib/appsignal/cli/notify_of_deploy_spec.rb +2 -5
  44. data/spec/lib/appsignal/cli_spec.rb +2 -5
  45. data/spec/lib/appsignal/config_spec.rb +385 -158
  46. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +1 -3
  47. data/spec/lib/appsignal/event_formatter/active_record/instantiation_formatter_spec.rb +0 -2
  48. data/spec/lib/appsignal/event_formatter/active_record/sql_formatter_spec.rb +0 -2
  49. data/spec/lib/appsignal/event_formatter/elastic_search/search_formatter_spec.rb +0 -2
  50. data/spec/lib/appsignal/event_formatter/faraday/request_formatter_spec.rb +0 -2
  51. data/spec/lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter_spec.rb +0 -2
  52. data/spec/lib/appsignal/event_formatter/moped/query_formatter_spec.rb +0 -2
  53. data/spec/lib/appsignal/event_formatter_spec.rb +0 -2
  54. data/spec/lib/appsignal/extension_spec.rb +7 -8
  55. data/spec/lib/appsignal/garbage_collection_profiler_spec.rb +71 -0
  56. data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +42 -0
  57. data/spec/lib/appsignal/hooks/celluloid_spec.rb +0 -2
  58. data/spec/lib/appsignal/hooks/data_mapper_spec.rb +0 -2
  59. data/spec/lib/appsignal/hooks/delayed_job_spec.rb +0 -2
  60. data/spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb +0 -2
  61. data/spec/lib/appsignal/hooks/net_http_spec.rb +0 -2
  62. data/spec/lib/appsignal/hooks/passenger_spec.rb +0 -2
  63. data/spec/lib/appsignal/hooks/puma_spec.rb +0 -2
  64. data/spec/lib/appsignal/hooks/rake_spec.rb +1 -2
  65. data/spec/lib/appsignal/hooks/redis_spec.rb +0 -2
  66. data/spec/lib/appsignal/hooks/sequel_spec.rb +19 -21
  67. data/spec/lib/appsignal/hooks/shoryuken_spec.rb +1 -4
  68. data/spec/lib/appsignal/hooks/sidekiq_spec.rb +2 -3
  69. data/spec/lib/appsignal/hooks/unicorn_spec.rb +0 -2
  70. data/spec/lib/appsignal/hooks/webmachine_spec.rb +4 -11
  71. data/spec/lib/appsignal/hooks_spec.rb +0 -2
  72. data/spec/lib/appsignal/integrations/data_mapper_spec.rb +0 -1
  73. data/spec/lib/appsignal/integrations/grape_spec.rb +1 -3
  74. data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +1 -2
  75. data/spec/lib/appsignal/integrations/object_spec.rb +32 -3
  76. data/spec/lib/appsignal/integrations/padrino_spec.rb +4 -11
  77. data/spec/lib/appsignal/integrations/railtie_spec.rb +1 -3
  78. data/spec/lib/appsignal/integrations/resque_active_job_spec.rb +1 -3
  79. data/spec/lib/appsignal/integrations/resque_spec.rb +2 -4
  80. data/spec/lib/appsignal/integrations/sinatra_spec.rb +33 -8
  81. data/spec/lib/appsignal/integrations/webmachine_spec.rb +6 -15
  82. data/spec/lib/appsignal/js_exception_transaction_spec.rb +3 -5
  83. data/spec/lib/appsignal/marker_spec.rb +35 -48
  84. data/spec/lib/appsignal/minutely_spec.rb +0 -2
  85. data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +0 -2
  86. data/spec/lib/appsignal/rack/js_exception_catcher_spec.rb +0 -2
  87. data/spec/lib/appsignal/rack/rails_instrumentation_spec.rb +3 -5
  88. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +47 -11
  89. data/spec/lib/appsignal/rack/streaming_listener_spec.rb +6 -7
  90. data/spec/lib/appsignal/system/container_spec.rb +67 -0
  91. data/spec/lib/appsignal/system_spec.rb +49 -0
  92. data/spec/lib/appsignal/transaction_spec.rb +30 -13
  93. data/spec/lib/appsignal/transmitter_spec.rb +53 -20
  94. data/spec/lib/appsignal/utils/gzip_spec.rb +10 -0
  95. data/spec/lib/appsignal/utils/params_sanitizer_spec.rb +0 -2
  96. data/spec/lib/appsignal/utils/query_params_sanitizer_spec.rb +0 -2
  97. data/spec/lib/appsignal/utils_spec.rb +59 -3
  98. data/spec/lib/appsignal_spec.rb +132 -58
  99. data/spec/spec_helper.rb +24 -116
  100. data/spec/support/fixtures/containers/cgroups/docker +14 -0
  101. data/spec/support/fixtures/containers/cgroups/docker_systemd +8 -0
  102. data/spec/support/fixtures/containers/cgroups/lxc +10 -0
  103. data/spec/support/fixtures/containers/cgroups/no_permission +0 -0
  104. data/spec/support/fixtures/containers/cgroups/none +1 -0
  105. data/spec/support/helpers/api_request_helper.rb +22 -0
  106. data/spec/support/helpers/dependency_helper.rb +61 -0
  107. data/spec/support/helpers/directory_helper.rb +27 -0
  108. data/spec/support/helpers/std_streams_helper.rb +35 -0
  109. data/spec/support/helpers/system_helpers.rb +24 -0
  110. data/spec/support/helpers/transaction_helpers.rb +7 -64
  111. data/spec/support/helpers/very_specific_error.rb +8 -0
  112. data/spec/support/mocks/fake_gc_profiler.rb +19 -0
  113. data/spec/support/project_fixture/config/appsignal.yml +10 -1
  114. metadata +60 -35
  115. data/circle.yml +0 -12
  116. data/lib/appsignal/subscriber.rb +0 -55
  117. data/lib/appsignal/update_active_support.rb +0 -20
  118. data/lib/vendor/active_support/notifications.rb +0 -212
  119. data/lib/vendor/active_support/notifications/fanout.rb +0 -157
  120. data/lib/vendor/active_support/notifications/instrumenter.rb +0 -73
  121. data/lib/vendor/active_support/per_thread_registry.rb +0 -53
  122. data/spec/lib/appsignal/subscriber_spec.rb +0 -160
  123. data/spec/lib/appsignal/update_active_support_spec.rb +0 -17
  124. data/spec/support/helpers/notification_helpers.rb +0 -14
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- if rails_present?
1
+ if DependencyHelper.rails_present?
4
2
  require 'action_view'
5
3
 
6
4
  describe Appsignal::EventFormatter::ActionView::RenderFormatter do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::ActiveRecord::InstantiationFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::ActiveRecord::InstantiationFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::ActiveRecord::InstantiationFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::ActiveRecord::SqlFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::ElasticSearch::SearchFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::ElasticSearch::SearchFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::Faraday::RequestFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::Faraday::RequestFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter do
4
2
  let(:formatter) { Appsignal::EventFormatter::MongoRubyDriver::QueryFormatter }
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::EventFormatter::Moped::QueryFormatter do
4
2
  let(:klass) { Appsignal::EventFormatter::Moped::QueryFormatter }
5
3
  let(:formatter) { klass.new }
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  class MockFormatter < Appsignal::EventFormatter
4
2
  register 'mock'
5
3
 
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'fileutils'
3
2
 
4
3
  describe "extension loading and operation" do
@@ -38,26 +37,26 @@ describe "extension loading and operation" do
38
37
  end
39
38
 
40
39
  context "with a transaction" do
41
- subject { Appsignal::Extension.start_transaction('request_id', 'http_request') }
40
+ subject { Appsignal::Extension.start_transaction('request_id', 'http_request', 0) }
42
41
 
43
42
  it "should have a start_event method" do
44
- subject.start_event
43
+ subject.start_event(0)
45
44
  end
46
45
 
47
46
  it "should have a finish_event method" do
48
- subject.finish_event('name', 'title', 'body', 0)
47
+ subject.finish_event('name', 'title', 'body', 0, 0)
49
48
  end
50
49
 
51
50
  it "should have a record_event method" do
52
- subject.record_event('name', 'title', 'body', 0, 1000)
51
+ subject.record_event('name', 'title', 'body', 1000, 0, 1000)
53
52
  end
54
53
 
55
54
  it "should have a set_error method" do
56
- subject.set_error('name', 'message', '[backtrace]')
55
+ subject.set_error('name', 'message', Appsignal::Extension.data_map_new)
57
56
  end
58
57
 
59
58
  it "should have a set_sample_data method" do
60
- subject.set_sample_data('params', '{}')
59
+ subject.set_sample_data('params', Appsignal::Extension.data_map_new)
61
60
  end
62
61
 
63
62
  it "should have a set_action method" do
@@ -73,7 +72,7 @@ describe "extension loading and operation" do
73
72
  end
74
73
 
75
74
  it "should have a finish method" do
76
- subject.finish
75
+ subject.finish(0)
77
76
  end
78
77
 
79
78
  it "should have a complete method" do
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+ require_relative '../../support/mocks/fake_gc_profiler'
3
+
4
+ describe Appsignal::GarbageCollectionProfiler do
5
+ let(:internal_profiler) { FakeGCProfiler.new }
6
+
7
+ before do
8
+ allow_any_instance_of(Appsignal::GarbageCollectionProfiler)
9
+ .to receive(:internal_profiler)
10
+ .and_return(internal_profiler)
11
+ end
12
+
13
+ it "should have a total time of 0" do
14
+ expect(Appsignal::GarbageCollectionProfiler.new.total_time).to eq(0)
15
+ end
16
+
17
+ describe "after a GC run" do
18
+ before do
19
+ internal_profiler.total_time = 0.12345
20
+ @profiler = Appsignal::GarbageCollectionProfiler.new
21
+ end
22
+
23
+ it "should take the total time from Ruby's GC::Profiler" do
24
+ expect(@profiler.total_time).to eq(123)
25
+ end
26
+
27
+ it "should clear Ruby's GC::Profiler" do
28
+ expect(internal_profiler).to receive(:clear)
29
+ @profiler.total_time
30
+ end
31
+ end
32
+
33
+ describe "when the total GC time becomes too high" do
34
+ it "should reset" do
35
+ profiler = Appsignal::GarbageCollectionProfiler.new
36
+ internal_profiler.total_time = 2_147_483_647
37
+ expect(profiler.total_time).to eq(0)
38
+ end
39
+ end
40
+
41
+ describe "after multiple GC runs" do
42
+ it "should add all times from Ruby's GC::Profiler together" do
43
+ profiler = Appsignal::GarbageCollectionProfiler.new
44
+
45
+ 2.times do
46
+ internal_profiler.total_time = 0.12345
47
+ profiler.total_time
48
+ end
49
+
50
+ expect(profiler.total_time).to eq(246)
51
+ end
52
+ end
53
+
54
+ describe "in multiple threads, with a slow GC::Profiler" do
55
+ it "should not count garbage collection times twice" do
56
+ threads, results = [], []
57
+ internal_profiler.clear_delay = 0.001
58
+ internal_profiler.total_time = 0.12345
59
+
60
+ 2.times do
61
+ threads << Thread.new do
62
+ profiler = Appsignal::GarbageCollectionProfiler.new
63
+ results << profiler.total_time
64
+ end
65
+ end
66
+
67
+ threads.each(&:join)
68
+ expect(results).to eq([123, 0])
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,42 @@
1
+ describe Appsignal::Hooks::ActiveSupportNotificationsHook do
2
+ if active_support_present?
3
+ before :all do
4
+ start_agent
5
+ end
6
+ before do
7
+ Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
8
+ end
9
+
10
+ let(:notifier) { ActiveSupport::Notifications::Fanout.new }
11
+ let(:instrumenter) { ActiveSupport::Notifications::Instrumenter.new(notifier) }
12
+
13
+ its(:dependencies_present?) { should be_true }
14
+
15
+ it "should instrument an AS notifications instrument call with a block" do
16
+ expect( Appsignal::Transaction.current ).to receive(:start_event)
17
+ .at_least(:once)
18
+ expect( Appsignal::Transaction.current ).to receive(:finish_event)
19
+ .at_least(:once)
20
+ .with("sql.active_record", nil, 'SQL', 1)
21
+
22
+ return_value = instrumenter.instrument('sql.active_record', :sql => 'SQL') do
23
+ 'value'
24
+ end
25
+
26
+ expect(return_value).to eq 'value'
27
+ end
28
+
29
+ it "should not instrument events whose name starts with a bang" do
30
+ expect( Appsignal::Transaction.current ).not_to receive(:start_event)
31
+ expect( Appsignal::Transaction.current ).not_to receive(:finish_event)
32
+
33
+ return_value = instrumenter.instrument('!sql.active_record', :sql => 'SQL') do
34
+ 'value'
35
+ end
36
+
37
+ expect(return_value).to eq 'value'
38
+ end
39
+ else
40
+ its(:dependencies_present?) { should be_false }
41
+ end
42
+ end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::CelluloidHook do
4
2
  context "with celluloid" do
5
3
  before :all do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::DataMapperHook do
4
2
  context "with datamapper" do
5
3
  before :all do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::DelayedJobHook do
4
2
  context "with delayed job" do
5
3
  before(:all) do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::MongoRubyDriverHook do
4
2
  require 'appsignal/integrations/mongo_ruby_driver'
5
3
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::NetHttpHook do
4
2
  before :all do
5
3
  start_agent
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::PassengerHook do
4
2
  context "with passenger" do
5
3
  before(:all) do
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::PumaHook do
4
2
  context "with puma" do
5
3
  before(:all) do
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'rake'
3
2
 
4
3
  describe Appsignal::Hooks::RakeHook do
@@ -16,7 +15,7 @@ describe Appsignal::Hooks::RakeHook do
16
15
 
17
16
  describe "#execute" do
18
17
  context "with transaction" do
19
- let!(:transaction) { regular_transaction }
18
+ let!(:transaction) { background_job_transaction }
20
19
  let!(:agent) { double('Agent', :send_queue => true) }
21
20
  before do
22
21
  transaction.stub(:set_action)
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::RedisHook do
4
2
  before :all do
5
3
  start_agent
@@ -1,28 +1,26 @@
1
- require 'spec_helper'
1
+ describe Appsignal::Hooks::SequelHook do
2
+ if DependencyHelper.sequel_present?
3
+ let(:db) { Sequel.sqlite }
2
4
 
3
- describe Appsignal::Hooks::SequelHook, if: sequel_present? do
4
- let(:db) { Sequel.sqlite }
5
-
6
- before :all do
7
- start_agent
8
- end
5
+ before :all do
6
+ start_agent
7
+ end
9
8
 
10
- its(:dependencies_present?) { should be_true }
9
+ its(:dependencies_present?) { should be_true }
11
10
 
12
- context "with a transaction" do
13
- it "should instrument queries" do
14
- Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
15
- expect( Appsignal::Transaction.current ).to receive(:start_event)
16
- .at_least(:once)
17
- expect( Appsignal::Transaction.current ).to receive(:finish_event)
18
- .at_least(:once)
19
- .with("sql.sequel", nil, kind_of(String), 1)
11
+ context "with a transaction" do
12
+ it "should instrument queries" do
13
+ Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
14
+ expect( Appsignal::Transaction.current ).to receive(:start_event)
15
+ .at_least(:once)
16
+ expect( Appsignal::Transaction.current ).to receive(:finish_event)
17
+ .at_least(:once)
18
+ .with("sql.sequel", nil, kind_of(String), 1)
20
19
 
21
- db['SELECT 1'].all.to_a
20
+ db['SELECT 1'].all.to_a
21
+ end
22
22
  end
23
+ else
24
+ its(:dependencies_present?) { should be_false }
23
25
  end
24
26
  end
25
-
26
- describe Appsignal::Hooks::SequelHook, unless: sequel_present? do
27
- its(:dependencies_present?) { should be_false }
28
- end
@@ -1,6 +1,3 @@
1
- require 'spec_helper'
2
-
3
-
4
1
  describe Appsignal::Hooks::ShoryukenMiddleware do
5
2
  let(:current_transaction) { background_job_transaction }
6
3
 
@@ -51,7 +48,7 @@ describe Appsignal::Hooks::ShoryukenMiddleware do
51
48
  end
52
49
 
53
50
  context "with an erroring call" do
54
- let(:error) { VerySpecificError.new('on fire') }
51
+ let(:error) { VerySpecificError.new }
55
52
 
56
53
  it "should add the exception to appsignal" do
57
54
  Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::SidekiqPlugin do
4
2
  let(:worker) { double }
5
3
  let(:queue) { double }
@@ -79,7 +77,8 @@ describe Appsignal::Hooks::SidekiqPlugin do
79
77
  end
80
78
 
81
79
  context "with an erroring call" do
82
- let(:error) { VerySpecificError.new('the roof') }
80
+ let(:error) { VerySpecificError.new }
81
+
83
82
  it "should add the exception to appsignal" do
84
83
  Appsignal::Transaction.any_instance.should_receive(:set_error).with(error)
85
84
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Hooks::UnicornHook do
4
2
  context "with unicorn" do
5
3
  before :all do
@@ -1,17 +1,11 @@
1
- require 'spec_helper'
2
-
3
- if webmachine_present?
4
-
5
- describe Appsignal::Hooks::WebmachineHook do
1
+ describe Appsignal::Hooks::WebmachineHook do
2
+ if DependencyHelper.webmachine_present?
6
3
  context "with webmachine" do
7
- before(:all) do
8
- Appsignal::Hooks::WebmachineHook.new.install
9
- end
4
+ let(:fsm) { Webmachine::Decision::FSM.new(double(:trace? => false), double, double) }
5
+ before(:all) { start_agent }
10
6
 
11
7
  its(:dependencies_present?) { should be_true }
12
8
 
13
- let(:fsm) { Webmachine::Decision::FSM.new(double(:trace? => false), double, double) }
14
-
15
9
  it "should include the run alias methods" do
16
10
  expect( fsm ).to respond_to(:run_with_appsignal)
17
11
  expect( fsm ).to respond_to(:run_without_appsignal)
@@ -28,5 +22,4 @@ if webmachine_present?
28
22
  end
29
23
  end
30
24
  end
31
-
32
25
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  class MockPresentHook < Appsignal::Hooks::Hook
4
2
  def dependencies_present?
5
3
  true
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/integrations/data_mapper'
3
2
 
4
3
  describe Appsignal::Hooks::DataMapperLogListener do
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- if grape_present?
1
+ if DependencyHelper.grape_present?
4
2
  require 'appsignal/integrations/grape'
5
3
 
6
4
  describe Appsignal::Grape::Middleware do
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/integrations/mongo_ruby_driver'
3
2
  describe Appsignal::Hooks::MongoMonitorSubscriber do
4
3
  let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
@@ -82,7 +81,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
82
81
  transaction.should receive(:finish_event).with(
83
82
  'query.mongodb',
84
83
  'find | test | SUCCEEDED',
85
- "{\"foo\":\"?\"}",
84
+ Appsignal::Utils.data_generate({'foo' => '?'}),
86
85
  0
87
86
  )
88
87
 
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/integrations/object'
3
2
 
4
3
  describe Object do
@@ -15,7 +14,7 @@ describe Object do
15
14
  let(:instance) { klass.new }
16
15
 
17
16
  context "when active" do
18
- let(:transaction) { regular_transaction }
17
+ let(:transaction) { http_request_transaction }
19
18
  before { Appsignal.config = project_fixture_config }
20
19
  after { Appsignal.config = nil }
21
20
 
@@ -93,6 +92,21 @@ describe Object do
93
92
  expect(instance.foo).to eq(1)
94
93
  end
95
94
  end
95
+
96
+ context "with a method given a block" do
97
+ let(:klass) do
98
+ Class.new do
99
+ def foo
100
+ yield
101
+ end
102
+ appsignal_instrument_method :foo
103
+ end
104
+ end
105
+
106
+ it "should yield the block" do
107
+ expect(instance.foo { 42 }).to eq(42)
108
+ end
109
+ end
96
110
  end
97
111
 
98
112
  context "when not active" do
@@ -117,7 +131,7 @@ describe Object do
117
131
  end
118
132
 
119
133
  context "when active" do
120
- let(:transaction) { regular_transaction }
134
+ let(:transaction) { http_request_transaction }
121
135
  before { Appsignal.config = project_fixture_config }
122
136
  after { Appsignal.config = nil }
123
137
 
@@ -195,6 +209,21 @@ describe Object do
195
209
  expect(klass.bar).to eq(2)
196
210
  end
197
211
  end
212
+
213
+ context "with a method given a block" do
214
+ let(:klass) do
215
+ Class.new do
216
+ def self.bar
217
+ yield
218
+ end
219
+ appsignal_instrument_class_method :bar
220
+ end
221
+ end
222
+
223
+ it "should yield the block" do
224
+ expect(klass.bar { 42 }).to eq(42)
225
+ end
226
+ end
198
227
  end
199
228
 
200
229
  context "when not active" do