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,11 +1,4 @@
1
- require 'spec_helper'
2
-
3
- begin
4
- require 'padrino'
5
- rescue LoadError
6
- end
7
-
8
- if padrino_present?
1
+ if DependencyHelper.padrino_present?
9
2
  describe "Padrino integration" do
10
3
  require File.expand_path('lib/appsignal/integrations/padrino.rb')
11
4
 
@@ -100,7 +93,7 @@ if padrino_present?
100
93
  end
101
94
 
102
95
  it "should not instrument the request" do
103
- expect( ActiveSupport::Notifications ).to_not receive(:instrument)
96
+ expect( Appsignal ).to_not receive(:instrument)
104
97
  end
105
98
 
106
99
  after { router.route!(base) }
@@ -114,7 +107,7 @@ if padrino_present?
114
107
  end
115
108
 
116
109
  it "should not instrument the request" do
117
- expect( ActiveSupport::Notifications ).to_not receive(:instrument)
110
+ expect( Appsignal ).to_not receive(:instrument)
118
111
  end
119
112
 
120
113
  after { router.route!(base) }
@@ -146,7 +139,7 @@ if padrino_present?
146
139
  end
147
140
 
148
141
  it "should instrument the action" do
149
- expect( ActiveSupport::Notifications ).to receive(:instrument).with('process_action.padrino')
142
+ expect( Appsignal ).to receive(:instrument).with('process_action.padrino')
150
143
  end
151
144
 
152
145
  it "should set metadata" do
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- if rails_present?
1
+ if DependencyHelper.rails_present?
4
2
  describe Appsignal::Integrations::Railtie do
5
3
  context "after initializing the app" do
6
4
  it "should call initialize_appsignal" do
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- if resque_present? && active_job_present?
1
+ if DependencyHelper.resque_present? && DependencyHelper.active_job_present?
4
2
  describe "Resque ActiveJob integration" do
5
3
  let(:file) { File.expand_path('lib/appsignal/integrations/resque_active_job.rb') }
6
4
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- if resque_present?
1
+ if DependencyHelper.resque_present?
4
2
  describe "Resque integration" do
5
3
  let(:file) { File.expand_path('lib/appsignal/integrations/resque.rb') }
6
4
 
@@ -20,7 +18,7 @@ if resque_present?
20
18
  extend Appsignal::Integrations::ResquePlugin
21
19
 
22
20
  def self.perform
23
- raise VerySpecificError.new('broken')
21
+ raise VerySpecificError.new
24
22
  end
25
23
  end
26
24
  end
@@ -1,20 +1,45 @@
1
- require 'spec_helper'
2
-
3
- if sinatra_present? && !padrino_present?
1
+ if DependencyHelper.sinatra_present?
4
2
  ENV['APPSIGNAL_PUSH_API_KEY'] = 'key'
5
3
  require 'appsignal/integrations/sinatra'
6
4
 
7
5
  describe "Sinatra integration" do
8
- context "logger" do
6
+ context "Appsignal.logger" do
9
7
  subject { Appsignal.logger }
10
8
 
11
9
  it { should be_a Logger }
12
10
  end
13
11
 
14
- it "should have added the instrumentation middleware" do
15
- Sinatra::Base.middleware.to_a.should include(
16
- [Appsignal::Rack::SinatraBaseInstrumentation, [], nil]
17
- )
12
+ describe "middleware" do
13
+ it "adds the instrumentation middleware to Sinatra::Base" do
14
+ Sinatra::Base.middleware.to_a.should include(
15
+ [Appsignal::Rack::SinatraBaseInstrumentation, [], nil]
16
+ )
17
+ end
18
+ end
19
+
20
+ describe "environment" do
21
+ subject { Appsignal.config.env }
22
+
23
+ context "without APPSIGNAL_APP_ENV" do
24
+ before do
25
+ load File.expand_path('lib/appsignal/integrations/sinatra.rb', project_dir)
26
+ end
27
+
28
+ it "uses the app environment" do
29
+ expect(subject).to eq('test')
30
+ end
31
+ end
32
+
33
+ context "with APPSIGNAL_APP_ENV" do
34
+ before do
35
+ ENV['APPSIGNAL_APP_ENV'] = 'env-staging'
36
+ load File.expand_path('lib/appsignal/integrations/sinatra.rb', project_dir)
37
+ end
38
+
39
+ it "uses the environment variable" do
40
+ expect(subject).to eq('env-staging')
41
+ end
42
+ end
18
43
  end
19
44
  end
20
45
  end
@@ -1,20 +1,15 @@
1
- require 'spec_helper'
2
- if webmachine_present?
3
-
1
+ if DependencyHelper.webmachine_present?
4
2
  require 'appsignal/integrations/webmachine'
5
3
 
6
4
  describe Appsignal::Integrations::WebmachinePlugin::FSM do
7
- before(:all) do
8
- Appsignal::Hooks::WebmachineHook.new.install
9
- end
10
5
  let(:request) do
11
6
  Webmachine::Request.new('GET', 'http://google.com:80/foo', {}, nil)
12
7
  end
13
8
  let(:resource) { double(:trace? => false, :handle_exception => true) }
14
9
  let(:response) { double }
15
10
  let(:transaction) { double(:set_action => true) }
16
-
17
11
  let(:fsm) { Webmachine::Decision::FSM.new(resource, request, response) }
12
+ before(:all) { start_agent }
18
13
 
19
14
  # Make sure the request responds to the method we need to get query params.
20
15
  describe "request" do
@@ -49,7 +44,7 @@ if webmachine_present?
49
44
  end
50
45
 
51
46
  it "should instrument the original method" do
52
- expect( ActiveSupport::Notifications ).to receive(:instrument).with('process_action.webmachine')
47
+ expect( Appsignal ).to receive(:instrument).with('process_action.webmachine')
53
48
  end
54
49
 
55
50
  it "should close the transaction" do
@@ -59,20 +54,16 @@ if webmachine_present?
59
54
  after { fsm.run }
60
55
  end
61
56
 
62
- describe "handle_exceptions_with_appsignal" do
63
- let(:error) { VerySpecificError.new('error') }
57
+ describe "#handle_exceptions_with_appsignal" do
58
+ let(:error) { VerySpecificError.new }
64
59
 
65
60
  it "should catch the error and send it to AppSignal" do
66
61
  expect( Appsignal ).to receive(:set_error).with(error)
67
62
  end
68
63
 
69
64
  after do
70
- begin
71
- fsm.send(:handle_exceptions) { raise error };
72
- rescue VerySpecificError
73
- end
65
+ fsm.send(:handle_exceptions) { raise error }
74
66
  end
75
67
  end
76
-
77
68
  end
78
69
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::JSExceptionTransaction do
4
2
  before { SecureRandom.stub(:uuid => '123abc') }
5
3
 
@@ -23,7 +21,7 @@ describe Appsignal::JSExceptionTransaction do
23
21
 
24
22
  describe "#initialize" do
25
23
  it "should call all required methods" do
26
- expect( Appsignal::Extension ).to receive(:start_transaction).with('123abc', 'frontend').and_return(1)
24
+ expect( Appsignal::Extension ).to receive(:start_transaction).with('123abc', 'frontend', 0).and_return(1)
27
25
 
28
26
  expect( transaction ).to receive(:set_action)
29
27
  expect( transaction ).to receive(:set_metadata)
@@ -62,7 +60,7 @@ describe Appsignal::JSExceptionTransaction do
62
60
  expect( transaction.ext ).to receive(:set_error).with(
63
61
  'TypeError',
64
62
  'foo is not a valid method',
65
- "[\"foo.bar/js:11:1\",\"foo.bar/js:22:2\"]"
63
+ Appsignal::Utils.data_generate(['foo.bar/js:11:1', 'foo.bar/js:22:2'])
66
64
  )
67
65
 
68
66
  transaction.set_error
@@ -73,7 +71,7 @@ describe Appsignal::JSExceptionTransaction do
73
71
  it "should call `Appsignal::Extension.set_transaction_error_data`" do
74
72
  expect( transaction.ext ).to receive(:set_sample_data).with(
75
73
  'tags',
76
- '["tag1"]'
74
+ Appsignal::Utils.data_generate(['tag1'])
77
75
  )
78
76
 
79
77
  transaction.set_sample_data
@@ -1,9 +1,7 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Marker do
4
2
  let(:config) { project_fixture_config }
5
- let(:marker) {
6
- Appsignal::Marker.new(
3
+ let(:marker) do
4
+ described_class.new(
7
5
  {
8
6
  :revision => '503ce0923ed177a3ce000005',
9
7
  :repository => 'master',
@@ -12,57 +10,46 @@ describe Appsignal::Marker do
12
10
  },
13
11
  config
14
12
  )
15
- }
16
- let(:out_stream) { StringIO.new }
17
- before do
18
- @original_stdout = $stdout
19
- $stdout = out_stream
20
13
  end
21
- after do
22
- $stdout = @original_stdout
14
+ let(:out_stream) { StringIO.new }
15
+ around do |example|
16
+ capture_stdout(out_stream) { example.run }
23
17
  end
24
18
 
25
- context "transmit" do
26
- let(:transmitter) { double }
27
- before do
28
- Appsignal::Transmitter.should_receive(:new).with(
29
- 'markers', config
30
- ).and_return(transmitter)
31
- end
32
-
33
- it "should transmit data" do
34
- transmitter.should_receive(:transmit).with(
35
- :revision => '503ce0923ed177a3ce000005',
36
- :repository => 'master',
37
- :user => 'batman',
38
- :rails_env => 'production'
39
- )
40
-
41
- marker.transmit
19
+ describe "#transmit" do
20
+ def stub_marker_request
21
+ stub_api_request config, "markers", marker.marker_data
42
22
  end
43
23
 
44
- it "should log status 200" do
45
- transmitter.should_receive(:transmit).and_return('200')
46
-
47
- marker.transmit
48
-
49
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
50
- out_stream.string.should include('Appsignal has been notified of this deploy!')
24
+ context "when request is valid" do
25
+ before do
26
+ stub_marker_request.to_return(:status => 200)
27
+ marker.transmit
28
+ end
29
+
30
+ it "outputs success" do
31
+ output = out_stream.string
32
+ expect(output).to include \
33
+ 'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
34
+ 'Appsignal has been notified of this deploy!'
35
+ end
51
36
  end
52
37
 
53
- it "should log other status" do
54
- transmitter.should_receive(:transmit).and_return('500')
55
- transmitter.should_receive(:uri).and_return('http://localhost:3000/1/markers')
56
-
57
- marker.transmit
58
-
59
- out_stream.string.should include('Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman')
60
- out_stream.string.should include(
61
- 'Something went wrong while trying to notify Appsignal: 500 at http://localhost:3000/1/markers'
62
- )
63
- out_stream.string.should_not include(
64
- 'Appsignal has been notified of this deploy!'
65
- )
38
+ context "when request is invalid" do
39
+ before do
40
+ stub_marker_request.to_return(:status => 500)
41
+ marker.transmit
42
+ end
43
+
44
+ it "outputs failure" do
45
+ output = out_stream.string
46
+ expect(output).to include \
47
+ 'Notifying Appsignal of deploy with: revision: 503ce0923ed177a3ce000005, user: batman',
48
+ "Something went wrong while trying to notify Appsignal: 500 at "\
49
+ "#{config[:endpoint]}/1/markers"
50
+ expect(output).to_not include \
51
+ 'Appsignal has been notified of this deploy!'
52
+ end
66
53
  end
67
54
  end
68
55
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Minutely do
4
2
  before do
5
3
  Appsignal::Minutely.probes.clear
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Rack::GenericInstrumentation do
4
2
  before :all do
5
3
  start_agent
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Appsignal::Rack::JSExceptionCatcher do
4
2
  let(:app) { double(:call => true) }
5
3
  let(:options) { double }
@@ -1,9 +1,7 @@
1
- require 'spec_helper'
2
-
3
- class MockController
4
- end
1
+ if DependencyHelper.rails_present?
2
+ class MockController
3
+ end
5
4
 
6
- if defined?(::Rails)
7
5
  describe Appsignal::Rack::RailsInstrumentation do
8
6
  before :all do
9
7
  start_agent
@@ -1,12 +1,6 @@
1
- require 'spec_helper'
2
-
3
- begin
4
- require 'sinatra'
1
+ if DependencyHelper.sinatra_present?
5
2
  require 'appsignal/integrations/sinatra'
6
- rescue LoadError
7
- end
8
3
 
9
- if defined?(::Sinatra)
10
4
  describe Appsignal::Rack::SinatraInstrumentation do
11
5
  let(:settings) { double(:raise_errors => false) }
12
6
  let(:app) { double(:call => true, :settings => settings) }
@@ -47,6 +41,40 @@ if defined?(::Sinatra)
47
41
  let(:options) { {} }
48
42
  let(:middleware) { Appsignal::Rack::SinatraBaseInstrumentation.new(app, options) }
49
43
 
44
+ describe "#initialize" do
45
+ context "with no settings method in the Sinatra app" do
46
+ let(:app) { double(:call => true) }
47
+
48
+ it "should not raise errors" do
49
+ expect( middleware.raise_errors_on ).to be(false)
50
+ end
51
+ end
52
+
53
+ context "with no raise_errors setting in the Sinatra app" do
54
+ let(:app) { double(:call => true, :settings => double) }
55
+
56
+ it "should not raise errors" do
57
+ expect( middleware.raise_errors_on ).to be(false)
58
+ end
59
+ end
60
+
61
+ context "with raise_errors turned off in the Sinatra app" do
62
+ let(:app) { double(:call => true, :settings => double(:raise_errors => false)) }
63
+
64
+ it "should raise errors" do
65
+ expect( middleware.raise_errors_on ).to be(false)
66
+ end
67
+ end
68
+
69
+ context "with raise_errors turned on in the Sinatra app" do
70
+ let(:app) { double(:call => true, :settings => double(:raise_errors => true)) }
71
+
72
+ it "should raise errors" do
73
+ expect( middleware.raise_errors_on ).to be(true)
74
+ end
75
+ end
76
+ end
77
+
50
78
  describe "#call" do
51
79
  before do
52
80
  middleware.stub(:raw_payload => {})
@@ -133,11 +161,11 @@ if defined?(::Sinatra)
133
161
  Appsignal::Transaction.any_instance.should_receive(:set_action).with('GET /')
134
162
  end
135
163
 
136
- context "with option to set path a mounted_at prefix" do
137
- let(:options) {{ :mounted_at => "/api/v2" }}
164
+ context "without 'sinatra.route' env" do
165
+ let(:env) { {:path => '/', :method => 'GET'} }
138
166
 
139
- it "should call set_action with a prefix path" do
140
- Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /api/v2/")
167
+ it "returns nil" do
168
+ Appsignal::Transaction.any_instance.should_receive(:set_action).with(nil)
141
169
  end
142
170
  end
143
171
 
@@ -147,6 +175,14 @@ if defined?(::Sinatra)
147
175
  it "should call set_action with an application prefix path" do
148
176
  Appsignal::Transaction.any_instance.should_receive(:set_action).with("GET /api/")
149
177
  end
178
+
179
+ context "without 'sinatra.route' env" do
180
+ let(:env) { {:path => '/', :method => 'GET'} }
181
+
182
+ it "returns nil" do
183
+ Appsignal::Transaction.any_instance.should_receive(:set_action).with(nil)
184
+ end
185
+ end
150
186
  end
151
187
  end
152
188
 
@@ -1,4 +1,3 @@
1
- require 'spec_helper'
2
1
  require 'appsignal/rack/streaming_listener'
3
2
 
4
3
  describe Appsignal::Rack::StreamingListener do
@@ -60,7 +59,7 @@ describe Appsignal::Rack::StreamingListener do
60
59
  end
61
60
 
62
61
  it "should instrument the call" do
63
- expect( ActiveSupport::Notifications ).to receive(:instrument)
62
+ expect( Appsignal ).to receive(:instrument)
64
63
  .with('process_action.rack')
65
64
  .and_yield
66
65
 
@@ -68,7 +67,7 @@ describe Appsignal::Rack::StreamingListener do
68
67
  end
69
68
 
70
69
  it "should add `appsignal.action` to the transaction" do
71
- allow( ActiveSupport::Notifications ).to receive(:instrument).and_yield
70
+ allow( Appsignal ).to receive(:instrument).and_yield
72
71
 
73
72
  env['appsignal.action'] = 'Action'
74
73
 
@@ -78,7 +77,7 @@ describe Appsignal::Rack::StreamingListener do
78
77
  end
79
78
 
80
79
  it "should add the path, method and queue start to the transaction" do
81
- allow( ActiveSupport::Notifications ).to receive(:instrument).and_yield
80
+ allow( Appsignal ).to receive(:instrument).and_yield
82
81
 
83
82
  expect( transaction ).to receive(:set_metadata).with('path', '/homepage')
84
83
  expect( transaction ).to receive(:set_metadata).with('method', 'GET')
@@ -89,7 +88,7 @@ describe Appsignal::Rack::StreamingListener do
89
88
 
90
89
  context "with an exception in the instrumentation call" do
91
90
  it "should add the exception to the transaction" do
92
- allow( app ).to receive(:call).and_raise(VerySpecificError.new('broken'))
91
+ allow( app ).to receive(:call).and_raise(VerySpecificError.new)
93
92
 
94
93
  expect( transaction ).to receive(:set_error)
95
94
 
@@ -124,7 +123,7 @@ describe Appsignal::StreamWrapper do
124
123
  context "when each raises an error" do
125
124
  it "should add the exception to the transaction" do
126
125
  allow( stream ).to receive(:each)
127
- .and_raise(VerySpecificError.new('broken'))
126
+ .and_raise(VerySpecificError.new)
128
127
 
129
128
  expect( transaction ).to receive(:set_error)
130
129
 
@@ -144,7 +143,7 @@ describe Appsignal::StreamWrapper do
144
143
  context "when each raises an error" do
145
144
  it "should add the exception to the transaction and close it" do
146
145
  allow( stream ).to receive(:close)
147
- .and_raise(VerySpecificError.new('broken'))
146
+ .and_raise(VerySpecificError.new)
148
147
 
149
148
  expect( transaction ).to receive(:set_error)
150
149
  expect( Appsignal::Transaction ).to receive(:complete_current!)