appsignal 0.11.18 → 0.12.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG.md +4 -38
  3. data/Rakefile +14 -6
  4. data/appsignal.gemspec +3 -1
  5. data/benchmark.rake +12 -16
  6. data/ext/appsignal_extension.c +183 -0
  7. data/ext/extconf.rb +39 -0
  8. data/gemfiles/capistrano2.gemfile +0 -1
  9. data/gemfiles/capistrano3.gemfile +0 -1
  10. data/gemfiles/rails-4.2.gemfile +1 -1
  11. data/lib/appsignal.rb +23 -61
  12. data/lib/appsignal/capistrano.rb +1 -2
  13. data/lib/appsignal/config.rb +13 -1
  14. data/lib/appsignal/event_formatter.rb +67 -0
  15. data/lib/appsignal/event_formatter/action_view/render_formatter.rb +23 -0
  16. data/lib/appsignal/event_formatter/active_record/sql_formatter.rb +74 -0
  17. data/lib/appsignal/event_formatter/moped/query_formatter.rb +80 -0
  18. data/lib/appsignal/event_formatter/net_http/request_formatter.rb +13 -0
  19. data/lib/appsignal/instrumentations/net_http.rb +6 -4
  20. data/lib/appsignal/integrations/resque.rb +2 -10
  21. data/lib/appsignal/integrations/sidekiq.rb +2 -2
  22. data/lib/appsignal/integrations/sinatra.rb +1 -0
  23. data/lib/appsignal/js_exception_transaction.rb +44 -28
  24. data/lib/appsignal/marker.rb +11 -13
  25. data/lib/appsignal/params_sanitizer.rb +5 -8
  26. data/lib/appsignal/rack/instrumentation.rb +2 -0
  27. data/lib/appsignal/rack/js_exception_catcher.rb +1 -0
  28. data/lib/appsignal/rack/listener.rb +1 -1
  29. data/lib/appsignal/rack/sinatra_instrumentation.rb +2 -12
  30. data/lib/appsignal/subscriber.rb +59 -0
  31. data/lib/appsignal/transaction.rb +117 -174
  32. data/lib/appsignal/transmitter.rb +8 -37
  33. data/lib/appsignal/version.rb +2 -1
  34. data/spec/lib/appsignal/config_spec.rb +25 -4
  35. data/spec/lib/appsignal/event_formatter/action_view/render_formatter_spec.rb +42 -0
  36. data/spec/lib/appsignal/{aggregator/middleware/active_record_sanitizer_spec.rb → event_formatter/active_record/sql_formatter_spec.rb} +61 -61
  37. data/spec/lib/appsignal/{event/moped_event_spec.rb → event_formatter/moped/query_formatter_spec.rb} +32 -78
  38. data/spec/lib/appsignal/event_formatter/net_http/request_formatter_spec.rb +26 -0
  39. data/spec/lib/appsignal/event_formatter_spec.rb +102 -0
  40. data/spec/lib/appsignal/extension_spec.rb +75 -0
  41. data/spec/lib/appsignal/instrumentations/net_http_spec.rb +20 -4
  42. data/spec/lib/appsignal/integrations/delayed_job_spec.rb +3 -2
  43. data/spec/lib/appsignal/integrations/rails_spec.rb +0 -7
  44. data/spec/lib/appsignal/integrations/resque_spec.rb +51 -55
  45. data/spec/lib/appsignal/integrations/sequel_spec.rb +8 -3
  46. data/spec/lib/appsignal/integrations/sidekiq_spec.rb +4 -21
  47. data/spec/lib/appsignal/integrations/sinatra_spec.rb +0 -6
  48. data/spec/lib/appsignal/js_exception_transaction_spec.rb +57 -60
  49. data/spec/lib/appsignal/params_sanitizer_spec.rb +11 -27
  50. data/spec/lib/appsignal/rack/listener_spec.rb +6 -6
  51. data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +2 -43
  52. data/spec/lib/appsignal/subscriber_spec.rb +162 -0
  53. data/spec/lib/appsignal/transaction_spec.rb +283 -615
  54. data/spec/lib/appsignal/transmitter_spec.rb +3 -32
  55. data/spec/lib/appsignal_spec.rb +41 -90
  56. data/spec/lib/generators/appsignal/appsignal_generator_spec.rb +0 -17
  57. data/spec/spec_helper.rb +18 -22
  58. data/spec/support/helpers/notification_helpers.rb +1 -1
  59. data/spec/support/helpers/time_helpers.rb +11 -0
  60. data/spec/support/helpers/transaction_helpers.rb +6 -18
  61. data/spec/support/project_fixture/config/appsignal.yml +1 -2
  62. metadata +68 -78
  63. checksums.yaml +0 -7
  64. data/gemfiles/padrino-0.13.gemfile +0 -7
  65. data/gemfiles/resque.gemfile +0 -5
  66. data/lib/appsignal/agent.rb +0 -217
  67. data/lib/appsignal/aggregator.rb +0 -67
  68. data/lib/appsignal/aggregator/middleware.rb +0 -4
  69. data/lib/appsignal/aggregator/middleware/action_view_sanitizer.rb +0 -23
  70. data/lib/appsignal/aggregator/middleware/active_record_sanitizer.rb +0 -65
  71. data/lib/appsignal/aggregator/middleware/chain.rb +0 -101
  72. data/lib/appsignal/aggregator/middleware/delete_blanks.rb +0 -16
  73. data/lib/appsignal/aggregator/post_processor.rb +0 -32
  74. data/lib/appsignal/event.rb +0 -20
  75. data/lib/appsignal/event/moped_event.rb +0 -90
  76. data/lib/appsignal/integrations/padrino.rb +0 -64
  77. data/lib/appsignal/integrations/passenger.rb +0 -13
  78. data/lib/appsignal/integrations/rake.rb +0 -29
  79. data/lib/appsignal/integrations/unicorn.rb +0 -25
  80. data/lib/appsignal/ipc.rb +0 -68
  81. data/lib/appsignal/transaction/formatter.rb +0 -85
  82. data/lib/appsignal/transaction/params_sanitizer.rb +0 -4
  83. data/lib/appsignal/zipped_payload.rb +0 -37
  84. data/spec/lib/appsignal/agent_spec.rb +0 -592
  85. data/spec/lib/appsignal/aggregator/middleware/action_view_sanitizer_spec.rb +0 -44
  86. data/spec/lib/appsignal/aggregator/middleware/chain_spec.rb +0 -168
  87. data/spec/lib/appsignal/aggregator/middleware/delete_blanks_spec.rb +0 -37
  88. data/spec/lib/appsignal/aggregator/post_processor_spec.rb +0 -99
  89. data/spec/lib/appsignal/aggregator_spec.rb +0 -186
  90. data/spec/lib/appsignal/event_spec.rb +0 -48
  91. data/spec/lib/appsignal/integrations/padrino_spec.rb +0 -171
  92. data/spec/lib/appsignal/integrations/passenger_spec.rb +0 -22
  93. data/spec/lib/appsignal/integrations/rake_spec.rb +0 -92
  94. data/spec/lib/appsignal/integrations/unicorn_spec.rb +0 -48
  95. data/spec/lib/appsignal/ipc_spec.rb +0 -128
  96. data/spec/lib/appsignal/transaction/formatter_spec.rb +0 -247
  97. data/spec/lib/appsignal/zipped_payload_spec.rb +0 -42
@@ -22,12 +22,6 @@ if defined?(::Sinatra)
22
22
  it { should be_a(Appsignal::Config) }
23
23
  end
24
24
 
25
- context "agent" do
26
- subject { Appsignal.agent }
27
-
28
- it { should be_a(Appsignal::Agent) }
29
- end
30
-
31
25
  it "should have added the listener middleware" do
32
26
  Sinatra::Application.middleware.to_a.should include(
33
27
  [Appsignal::Rack::Listener, [], nil]
@@ -1,15 +1,16 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Appsignal::JSExceptionTransaction do
4
- let(:transaction) { Appsignal::JSExceptionTransaction.new(data) }
4
+ before { SecureRandom.stub(:uuid => '123abc') }
5
+
6
+ let!(:transaction) { Appsignal::JSExceptionTransaction.new(data) }
5
7
  let(:data) do
6
8
  {
7
9
  'name' => 'TypeError',
8
10
  'message' => 'foo is not a valid method',
9
11
  'action' => 'ExceptionIncidentComponent',
10
12
  'path' => 'foo.bar/moo',
11
- 'environment' => {"user_agent" => "Mozilla/5.0"},
12
- 'tags' => {"intercom_user_id" => "abc123"},
13
+ 'environment' => 'development',
13
14
  'backtrace' => [
14
15
  'foo.bar/js:11:1',
15
16
  'foo.bar/js:22:2',
@@ -17,77 +18,73 @@ describe Appsignal::JSExceptionTransaction do
17
18
  }
18
19
  end
19
20
 
20
- describe "#type" do
21
- it "should return `:exception`" do
22
- expect( transaction.type ).to eql :exception
23
- end
24
- end
21
+ describe "#initialize" do
22
+ it "should call all required methods" do
23
+ expect( Appsignal::Extension ).to receive(:start_transaction).with('123abc')
25
24
 
26
- describe "#action" do
27
- it "should return the action" do
28
- expect( transaction.action ).to eql 'ExceptionIncidentComponent'
29
- end
30
- end
25
+ expect( transaction ).to receive(:set_base_data)
26
+ expect( transaction ).to receive(:set_metadata)
27
+ expect( transaction ).to receive(:set_error)
28
+ expect( transaction ).to receive(:set_error_data)
31
29
 
32
- describe "#clear_events" do
33
- it "should respond to `clear_events!`" do
34
- expect( transaction ).to respond_to :clear_events!
30
+ transaction.send :initialize, data
35
31
  end
36
32
  end
37
33
 
38
- describe "#convert_values_to_primitives!" do
39
- it "should respond to `convert_values_to_primitives!`" do
40
- expect( transaction ).to respond_to :convert_values_to_primitives!
34
+ describe "#set_base_data" do
35
+ it "should call `Appsignal::Extension.set_transaction_basedata`" do
36
+ expect( Appsignal::Extension ).to receive(:set_transaction_basedata).with(
37
+ '123abc',
38
+ 'frontend',
39
+ 'ExceptionIncidentComponent',
40
+ 0
41
+ )
42
+
43
+ transaction.set_base_data
41
44
  end
42
45
  end
43
46
 
44
- describe "#events" do
45
- it "should respond to `events` with an empty array" do
46
- expect( transaction.events ).to eql []
47
- end
47
+ describe "#set_metadata" do
48
+ it "should call `Appsignal::Extension.set_transaction_metadata`" do
49
+ expect( Appsignal::Extension ).to receive(:set_transaction_metadata).with(
50
+ '123abc',
51
+ 'path',
52
+ 'foo.bar/moo'
53
+ )
54
+
55
+ transaction.set_metadata
56
+ end
48
57
  end
49
58
 
50
- describe "#to_hash" do
51
- around do |sample|
52
- Timecop.freeze(Time.at(123)) { sample.run }
53
- end
59
+ describe "#set_error" do
60
+ it "should call `Appsignal::Extension.set_transaction_error`" do
61
+ expect( Appsignal::Extension ).to receive(:set_transaction_error).with(
62
+ '123abc',
63
+ 'TypeError',
64
+ 'foo is not a valid method'
65
+ )
54
66
 
55
- before do
56
- SecureRandom.stub(:uuid => 'uuid')
57
- Appsignal.stub(:agent => double(:revision => 'abcdef'))
58
- end
67
+ transaction.set_error
68
+ end
69
+ end
59
70
 
60
- it "should generate a hash based on the given data" do
61
- expect( transaction.to_hash).to eql({
62
- :request_id => 'uuid',
63
- :log_entry => {
64
- :action => 'ExceptionIncidentComponent',
65
- :path => 'foo.bar/moo',
66
- :kind => 'frontend',
67
- :time => 123,
68
- :environment => {"user_agent" => "Mozilla/5.0"},
69
- :tags => {"intercom_user_id" => "abc123"},
70
- :revision => 'abcdef'
71
- },
72
- :exception => {
73
- :exception => 'TypeError',
74
- :message => 'foo is not a valid method',
75
- :backtrace => [
76
- 'foo.bar/js:11:1',
77
- 'foo.bar/js:22:2',
78
- ]
79
- },
80
- :failed => true
81
- })
82
- end
71
+ describe "#set_error_data" do
72
+ it "should call `Appsignal::Extension.set_transaction_error_data`" do
73
+ expect( Appsignal::Extension ).to receive(:set_transaction_error_data).with(
74
+ '123abc',
75
+ 'backtrace',
76
+ '["foo.bar/js:11:1","foo.bar/js:22:2"]'
77
+ )
83
78
 
84
- describe "#complete!" do
85
- it "should enqueue itself" do
86
- expect( Appsignal ).to receive(:enqueue).with(transaction)
79
+ transaction.set_error_data
80
+ end
81
+ end
87
82
 
88
- transaction.complete!
89
- end
83
+ describe "#complete!" do
84
+ it "should call all required methods" do
85
+ expect( Appsignal::Extension ).to receive(:finish_transaction).with('123abc')
86
+ transaction.complete!
90
87
  end
91
-
92
88
  end
89
+
93
90
  end
@@ -6,54 +6,39 @@ class ErrorOnInspect
6
6
  end
7
7
  end
8
8
 
9
- class ClassWithInspect
10
- def inspect
11
- "#<ClassWithInspect foo=\"bar\"/>"
12
- end
13
- end
14
-
15
9
  describe Appsignal::ParamsSanitizer do
16
10
  let(:klass) { Appsignal::ParamsSanitizer }
17
11
  let(:file) { uploaded_file }
18
12
  let(:params) do
19
13
  {
20
- :text => 'string',
21
- :file => file,
22
- :float => 0.0,
23
- :bool_true => true,
24
- :bool_false => false,
25
- :int => 1,
26
- :hash => {
27
- :nested_text => 'string',
14
+ :text => 'string',
15
+ :file => file,
16
+ :hash => {
17
+ :nested_text => 'string',
28
18
  :nested_array => [
29
19
  'something',
30
20
  'else',
31
21
  file,
32
22
  {
33
- :key => 'value',
23
+ :key => 'value',
34
24
  :file => file,
35
25
  },
36
- ErrorOnInspect.new,
37
- ClassWithInspect.new
26
+ ErrorOnInspect.new
38
27
  ]
39
28
  }
40
29
  }
41
30
  end
42
31
  let(:sanitized_params) { klass.sanitize(params) }
43
- let(:scrubbed_params) { klass.scrub(params) }
32
+ let(:scrubbed_params) { klass.scrub(params) }
44
33
 
45
34
  describe ".sanitize!" do
46
35
  subject { params }
47
36
  before { klass.sanitize!(subject) }
48
37
 
49
38
  it { should be_instance_of Hash }
50
- its([:text]) { should == 'string' }
51
- its([:file]) { should be_instance_of String }
52
- its([:file]) { should include '::UploadedFile' }
53
- its([:float]) { should == 0.0 }
54
- its([:int]) { should == 1 }
55
- its([:bool_true]) { should == 'true' }
56
- its([:bool_false]) { should == 'false' }
39
+ its([:text]) { should == 'string' }
40
+ its([:file]) { should be_instance_of String }
41
+ its([:file]) { should include '::UploadedFile' }
57
42
 
58
43
  context "hash" do
59
44
  subject { params[:hash] }
@@ -69,8 +54,7 @@ describe Appsignal::ParamsSanitizer do
69
54
  its([1]) { should == 'else' }
70
55
  its([2]) { should be_instance_of String }
71
56
  its([2]) { should include '::UploadedFile' }
72
- its([4]) { should == '#<ErrorOnInspect>' }
73
- its([5]) { should == '#<ClassWithInspect>' }
57
+ its([4]) { should == '#<ErrorOnInspect/>' }
74
58
 
75
59
  context "nested hash" do
76
60
  subject { params[:hash][:nested_array][3] }
@@ -19,7 +19,7 @@ describe Appsignal::Rack::Listener do
19
19
  let(:env) { {} }
20
20
 
21
21
  describe '#call' do
22
- let(:current) { double(:complete! => true, :add_exception => true) }
22
+ let(:current) { double(:request_id => '1', :set_error => true) }
23
23
  before do
24
24
  middleware.stub(:request_id => '1')
25
25
  Appsignal::Transaction.stub(:current => current)
@@ -31,7 +31,7 @@ describe Appsignal::Rack::Listener do
31
31
  end
32
32
 
33
33
  it 'should call complete! after the call' do
34
- current.should_receive(:complete!)
34
+ Appsignal::Transaction.should_receive(:complete_current!)
35
35
  end
36
36
 
37
37
  context "when not active" do
@@ -55,7 +55,7 @@ describe Appsignal::Rack::Listener do
55
55
  end
56
56
 
57
57
  it 'should catch the exception and notify the transaction of it' do
58
- current.should_receive(:add_exception)
58
+ current.should_receive(:set_error)
59
59
  middleware.call(env) rescue nil
60
60
  end
61
61
 
@@ -69,14 +69,14 @@ describe Appsignal::Rack::Listener do
69
69
  end
70
70
 
71
71
  it 'should ignore the error' do
72
- current.should_not_receive(:add_exception)
72
+ current.should_not_receive(:set_error)
73
73
  middleware.call(env) rescue nil
74
74
  end
75
75
  end
76
76
 
77
77
  describe 'after an error' do
78
- it 'should call complete! after the call' do
79
- current.should_receive(:complete!)
78
+ it 'should call complete_current! after the call' do
79
+ Appsignal::Transaction.should_receive(:complete_current!)
80
80
  end
81
81
 
82
82
  after { middleware.call(env) rescue nil }
@@ -23,34 +23,6 @@ if defined?(::Sinatra)
23
23
  let(:middleware) { Appsignal::Rack::SinatraInstrumentation.new(app, {}) }
24
24
 
25
25
  describe "#call" do
26
- before do
27
- middleware.stub(:raw_payload => {})
28
- end
29
-
30
- context "when appsignal is active" do
31
- before { Appsignal.stub(:active? => true) }
32
-
33
- it "should call with monitoring" do
34
- expect( middleware ).to receive(:call_with_appsignal_monitoring).with(env)
35
- end
36
- end
37
-
38
- context "when appsignal is not active" do
39
- before { Appsignal.stub(:active? => false) }
40
-
41
- it "should not call with monitoring" do
42
- expect( middleware ).to_not receive(:call_with_appsignal_monitoring)
43
- end
44
-
45
- it "should call the stack" do
46
- expect( app ).to receive(:call).with(env)
47
- end
48
- end
49
-
50
- after { middleware.call(env) }
51
- end
52
-
53
- describe "#call_with_appsignal_monitoring" do
54
26
  before do
55
27
  middleware.stub(:raw_payload => {})
56
28
  env['sinatra.route'] = 'GET /'
@@ -59,7 +31,7 @@ if defined?(::Sinatra)
59
31
  it "should instrument the call" do
60
32
  app.should_receive(:call).with(env)
61
33
 
62
- middleware.call_with_appsignal_monitoring(env)
34
+ middleware.call(env)
63
35
 
64
36
  process_action_event = @events.last
65
37
  process_action_event.name.should == 'process_action.sinatra'
@@ -70,26 +42,13 @@ if defined?(::Sinatra)
70
42
  app.should_receive(:call).with(env).and_raise('the roof')
71
43
 
72
44
  lambda {
73
- middleware.call_with_appsignal_monitoring(env)
45
+ middleware.call(env)
74
46
  }.should raise_error
75
47
 
76
48
  process_action_event = @events.last
77
49
  process_action_event.name.should == 'process_action.sinatra'
78
50
  process_action_event.payload[:action].should == 'GET /'
79
51
  end
80
-
81
- it "should add exceptions stored in env under sinatra.error" do
82
- exception = RuntimeError.new('Raise the roof')
83
- env['sinatra.error'] = exception
84
-
85
- transaction = double
86
- transaction.stub(:set_process_action_event)
87
- transaction.stub(:add_event)
88
- Appsignal.should_receive(:add_exception).with(exception)
89
- Appsignal::Transaction.stub(:current => transaction)
90
-
91
- middleware.call_with_appsignal_monitoring(env)
92
- end
93
52
  end
94
53
 
95
54
  describe "raw_payload" do
@@ -0,0 +1,162 @@
1
+ require 'spec_helper'
2
+
3
+ describe Appsignal::Subscriber do
4
+ before :all do
5
+ start_agent
6
+ end
7
+
8
+ before do
9
+ Thread.current[:appsignal_transaction] = nil
10
+ end
11
+
12
+ let(:subscriber) { Appsignal.subscriber }
13
+ subject { subscriber }
14
+
15
+ context "initialization" do
16
+ it "should be in the subscriber list" do
17
+ ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers).select do |s|
18
+ s.instance_variable_get(:@delegate).is_a?(Appsignal::Subscriber)
19
+ end.count == 1
20
+ end
21
+ end
22
+
23
+ context "subscriptions" do
24
+ describe "subscribe" do
25
+ it "should subscribe" do
26
+ ActiveSupport::Notifications.should_receive(:subscribe).with(/^[^!]/, subject).at_least(:once)
27
+
28
+ subject.subscribe
29
+ end
30
+ end
31
+
32
+ describe "#unsubscribe" do
33
+ it "should unsubscribe" do
34
+ ActiveSupport::Notifications.should_receive(:unsubscribe).with(subject).at_least(:once)
35
+
36
+ subject.unsubscribe
37
+ end
38
+ end
39
+
40
+ describe "#resubscribe" do
41
+ it "should unsubscribe and subscribe" do
42
+ subject.should_receive(:unsubscribe).at_least(:once)
43
+ subject.should_receive(:subscribe)
44
+
45
+ subject.resubscribe
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#publish" do
51
+ it "should exist" do
52
+ lambda {
53
+ subject.publish('name', '')
54
+ }.should_not raise_error
55
+ end
56
+ end
57
+
58
+ context "handling events using #start and #finish" do
59
+ it "should should not listen to events that start with a bang" do
60
+ subject.should_not_receive(:start)
61
+ subject.should_not_receive(:finish)
62
+
63
+ ActiveSupport::Notifications.instrument '!render_template'
64
+ end
65
+
66
+ it "should not record events when there is no current transaction" do
67
+ Appsignal::Extension.should_not_receive(:start_event)
68
+ Appsignal::Extension.should_not_receive(:finish_event)
69
+
70
+ lambda {
71
+ ActiveSupport::Notifications.instrument 'something'
72
+ }.should_not raise_error
73
+ end
74
+
75
+ context "with a current transaction" do
76
+ let(:transaction) { Appsignal::Transaction.current }
77
+
78
+ before do
79
+ Appsignal::Transaction.create('request-id', {})
80
+ end
81
+
82
+ it "should call native start and finish event for every event" do
83
+ Appsignal::Extension.should_receive(:start_event).exactly(4).times
84
+ Appsignal::Extension.should_receive(:finish_event).with('request-id', 'one', '', '').once
85
+ Appsignal::Extension.should_receive(:finish_event).with('request-id', 'two', '', '').once
86
+ Appsignal::Extension.should_receive(:finish_event).with('request-id', 'two.three', '', '').once
87
+ Appsignal::Extension.should_receive(:finish_event).with('request-id', 'one.three', '', '').once
88
+
89
+ ActiveSupport::Notifications.instrument('one') do
90
+ ActiveSupport::Notifications.instrument('two') do
91
+ ActiveSupport::Notifications.instrument('one.three') do
92
+ end
93
+ ActiveSupport::Notifications.instrument('two.three') do
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ it "should call finish with title and body if there is a formatter" do
100
+ Appsignal::Extension.should_receive(:start_event).once
101
+ Appsignal::Extension.should_receive(:finish_event).with(
102
+ 'request-id',
103
+ 'request.net_http',
104
+ 'GET http://www.google.com',
105
+ ''
106
+ ).once
107
+
108
+ ActiveSupport::Notifications.instrument(
109
+ 'request.net_http',
110
+ :protocol => 'http',
111
+ :domain => 'www.google.com',
112
+ :method => 'GET'
113
+ )
114
+ end
115
+
116
+ context "root event" do
117
+ it "should not set the root event for normal events" do
118
+ transaction.should_not_receive(:set_root_event)
119
+
120
+ ActiveSupport::Notifications.instrument 'something'
121
+ end
122
+
123
+ it "should set the root event when the name starts with process_action" do
124
+ transaction.respond_to?(:set_root_event).should be_true
125
+ transaction.should_receive(:set_root_event).with(
126
+ 'process_action.action_controller',
127
+ :params => {}
128
+ )
129
+
130
+ ActiveSupport::Notifications.instrument 'process_action.action_controller', {:params => {}}
131
+ end
132
+
133
+ it "should set the root event when the name starts with perform_job" do
134
+ transaction.respond_to?(:set_root_event).should be_true
135
+ transaction.should_receive(:set_root_event).with(
136
+ 'perform_job.resque',
137
+ :params => {}
138
+ )
139
+
140
+ ActiveSupport::Notifications.instrument 'perform_job.resque', {:params => {}}
141
+ end
142
+ end
143
+
144
+ context "when paused" do
145
+ before { transaction.pause! }
146
+
147
+ it "should set a root event, but no other events" do
148
+ Appsignal::Extension.should_not_receive(:start_event)
149
+ Appsignal::Extension.should_not_receive(:finish_event)
150
+
151
+ transaction.respond_to?(:set_root_event).should be_true
152
+ transaction.should_receive(:set_root_event).with(
153
+ 'perform_job.resque',
154
+ :params => {}
155
+ )
156
+
157
+ ActiveSupport::Notifications.instrument 'perform_job.resque', {:params => {}}
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end