appsignal 3.11.0-java → 3.12.1-java
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +115 -0
- data/Rakefile +1 -1
- data/lib/appsignal/cli/diagnose.rb +1 -1
- data/lib/appsignal/config.rb +150 -32
- data/lib/appsignal/demo.rb +1 -6
- data/lib/appsignal/helpers/instrumentation.rb +2 -2
- data/lib/appsignal/integrations/grape.rb +7 -0
- data/lib/appsignal/integrations/hanami.rb +8 -43
- data/lib/appsignal/integrations/padrino.rb +8 -73
- data/lib/appsignal/integrations/railtie.rb +35 -13
- data/lib/appsignal/integrations/sinatra.rb +8 -19
- data/lib/appsignal/loaders/grape.rb +13 -0
- data/lib/appsignal/loaders/hanami.rb +40 -0
- data/lib/appsignal/loaders/padrino.rb +68 -0
- data/lib/appsignal/loaders/sinatra.rb +24 -0
- data/lib/appsignal/loaders.rb +92 -0
- data/lib/appsignal/rack/abstract_middleware.rb +2 -1
- data/lib/appsignal/rack/event_handler.rb +5 -5
- data/lib/appsignal/rack.rb +6 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +163 -9
- data/spec/lib/appsignal/cli/demo_spec.rb +0 -1
- data/spec/lib/appsignal/cli/diagnose/paths_spec.rb +1 -1
- data/spec/lib/appsignal/cli/diagnose_spec.rb +0 -1
- data/spec/lib/appsignal/config_spec.rb +153 -1
- data/spec/lib/appsignal/demo_spec.rb +1 -2
- data/spec/lib/appsignal/environment_spec.rb +4 -2
- data/spec/lib/appsignal/hooks/active_support_notifications_spec.rb +3 -6
- data/spec/lib/appsignal/hooks/activejob_spec.rb +3 -3
- data/spec/lib/appsignal/hooks/dry_monitor_spec.rb +4 -7
- data/spec/lib/appsignal/hooks/excon_spec.rb +3 -6
- data/spec/lib/appsignal/hooks/gvl_spec.rb +2 -2
- data/spec/lib/appsignal/hooks/http_spec.rb +1 -3
- data/spec/lib/appsignal/hooks/net_http_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/redis_client_spec.rb +5 -8
- data/spec/lib/appsignal/hooks/redis_spec.rb +3 -6
- data/spec/lib/appsignal/hooks/resque_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/sequel_spec.rb +3 -5
- data/spec/lib/appsignal/hooks/sidekiq_spec.rb +1 -1
- data/spec/lib/appsignal/hooks/webmachine_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/delayed_job_plugin_spec.rb +2 -2
- data/spec/lib/appsignal/integrations/grape_spec.rb +36 -0
- data/spec/lib/appsignal/integrations/hanami_spec.rb +9 -178
- data/spec/lib/appsignal/integrations/http_spec.rb +1 -5
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +4 -2
- data/spec/lib/appsignal/integrations/net_http_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/object_spec.rb +1 -3
- data/spec/lib/appsignal/integrations/padrino_spec.rb +8 -330
- data/spec/lib/appsignal/integrations/railtie_spec.rb +275 -191
- data/spec/lib/appsignal/integrations/shoryuken_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/sidekiq_spec.rb +11 -9
- data/spec/lib/appsignal/integrations/sinatra_spec.rb +9 -104
- data/spec/lib/appsignal/loaders/grape_spec.rb +12 -0
- data/spec/lib/appsignal/loaders/hanami_spec.rb +95 -0
- data/spec/lib/appsignal/loaders/padrino_spec.rb +277 -0
- data/spec/lib/appsignal/loaders/sinatra_spec.rb +47 -0
- data/spec/lib/appsignal/loaders_spec.rb +137 -0
- data/spec/lib/appsignal/probes/sidekiq_spec.rb +1 -1
- data/spec/lib/appsignal/probes_spec.rb +6 -5
- data/spec/lib/appsignal/rack/abstract_middleware_spec.rb +3 -2
- data/spec/lib/appsignal/rack/event_handler_spec.rb +33 -0
- data/spec/lib/appsignal/rack/generic_instrumentation_spec.rb +1 -1
- data/spec/lib/appsignal/rack/grape_middleware_spec.rb +2 -35
- data/spec/lib/appsignal/rack/hanami_middleware_spec.rb +1 -1
- data/spec/lib/appsignal/rack/sinatra_instrumentation_spec.rb +3 -3
- data/spec/lib/appsignal/span_spec.rb +1 -3
- data/spec/lib/appsignal/transaction_spec.rb +61 -70
- data/spec/lib/appsignal_spec.rb +284 -26
- data/spec/lib/puma/appsignal_spec.rb +0 -3
- data/spec/spec_helper.rb +5 -4
- data/spec/support/helpers/config_helpers.rb +2 -1
- data/spec/support/helpers/loader_helper.rb +21 -0
- data/spec/support/matchers/transaction.rb +3 -2
- data/spec/support/stubs/appsignal/loaders/loader_stub.rb +7 -0
- data/spec/support/testing.rb +46 -0
- metadata +15 -2
@@ -1,186 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
if DependencyHelper.
|
3
|
+
if DependencyHelper.hanami_present?
|
4
4
|
describe "Hanami integration" do
|
5
|
-
|
5
|
+
it "loads the Hanami loader" do
|
6
|
+
ENV["APPSIGNAL_APP_NAME"] = "test/sinatra"
|
7
|
+
ENV["APPSIGNAL_PUSH_API_KEY"] = "test-key"
|
6
8
|
|
7
|
-
|
8
|
-
Appsignal.config = nil
|
9
|
-
allow(::Hanami::Action).to receive(:prepend)
|
10
|
-
uninstall_hanami_middleware
|
11
|
-
ENV["APPSIGNAL_APP_NAME"] = "hanamia-test-app"
|
12
|
-
ENV["APPSIGNAL_APP_ENV"] = "test"
|
13
|
-
ENV["APPSIGNAL_PUSH_API_KEY"] = "0000"
|
14
|
-
end
|
15
|
-
|
16
|
-
def uninstall_hanami_middleware
|
17
|
-
middleware_stack = ::Hanami.app.config.middleware.stack[::Hanami::Router::DEFAULT_PREFIX]
|
18
|
-
middleware_stack.delete_if do |middleware|
|
19
|
-
middleware.first == Appsignal::Rack::HanamiMiddleware ||
|
20
|
-
middleware.first == Rack::Events
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe Appsignal::Integrations::HanamiPlugin do
|
25
|
-
it "starts AppSignal on init" do
|
26
|
-
expect(Appsignal.active?).to be_falsey
|
27
|
-
|
28
|
-
Appsignal::Integrations::HanamiPlugin.init
|
29
|
-
|
30
|
-
expect(Appsignal.active?).to be_truthy
|
31
|
-
end
|
32
|
-
|
33
|
-
it "prepends the integration to Hanami::Action" do
|
34
|
-
Appsignal::Integrations::HanamiPlugin.init
|
35
|
-
|
36
|
-
expect(::Hanami::Action)
|
37
|
-
.to have_received(:prepend).with(Appsignal::Integrations::HanamiIntegration)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "adds middleware to the Hanami app" do
|
41
|
-
Appsignal::Integrations::HanamiPlugin.init
|
42
|
-
|
43
|
-
expect(::Hanami.app.config.middleware.stack[::Hanami::Router::DEFAULT_PREFIX])
|
44
|
-
.to include(
|
45
|
-
[Rack::Events, [[kind_of(Appsignal::Rack::EventHandler)]], *hanami_middleware_options],
|
46
|
-
[Appsignal::Rack::HanamiMiddleware, [], *hanami_middleware_options]
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
context "when not active" do
|
51
|
-
before do
|
52
|
-
ENV.delete("APPSIGNAL_APP_NAME")
|
53
|
-
ENV.delete("APPSIGNAL_APP_ENV")
|
54
|
-
ENV.delete("APPSIGNAL_PUSH_API_KEY")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "does not prepend the integration to Hanami::Action" do
|
58
|
-
Appsignal::Integrations::HanamiPlugin.init
|
59
|
-
|
60
|
-
expect(::Hanami::Action).to_not have_received(:prepend)
|
61
|
-
.with(Appsignal::Integrations::HanamiIntegration)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "does not add the middleware to the Hanami app" do
|
65
|
-
Appsignal::Integrations::HanamiPlugin.init
|
66
|
-
|
67
|
-
middleware_stack = ::Hanami.app.config.middleware.stack[::Hanami::Router::DEFAULT_PREFIX]
|
68
|
-
expect(middleware_stack).to_not include(
|
69
|
-
[Rack::Events, [[kind_of(Appsignal::Rack::EventHandler)]], *hanami_middleware_options]
|
70
|
-
)
|
71
|
-
expect(middleware_stack).to_not include(
|
72
|
-
[Appsignal::Rack::HanamiMiddleware, [], *hanami_middleware_options]
|
73
|
-
)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "when AppSignal is already active" do
|
78
|
-
before do
|
79
|
-
expect(Appsignal).to receive(:active?).at_least(1).and_return(true)
|
80
|
-
end
|
81
|
-
|
82
|
-
it "does not initialize AppSignal again" do
|
83
|
-
expect(Appsignal).to_not receive(:start)
|
84
|
-
|
85
|
-
Appsignal::Integrations::HanamiPlugin.init
|
86
|
-
end
|
87
|
-
|
88
|
-
it "prepends the integration to Hanami::Action" do
|
89
|
-
Appsignal::Integrations::HanamiPlugin.init
|
90
|
-
|
91
|
-
expect(::Hanami::Action)
|
92
|
-
.to have_received(:prepend).with(Appsignal::Integrations::HanamiIntegration)
|
93
|
-
end
|
94
|
-
|
95
|
-
it "adds middleware to the Hanami app" do
|
96
|
-
Appsignal::Integrations::HanamiPlugin.init
|
97
|
-
|
98
|
-
expect(::Hanami.app.config.middleware.stack[::Hanami::Router::DEFAULT_PREFIX])
|
99
|
-
.to include(
|
100
|
-
[
|
101
|
-
Rack::Events,
|
102
|
-
[[kind_of(Appsignal::Rack::EventHandler)]],
|
103
|
-
*hanami_middleware_options
|
104
|
-
],
|
105
|
-
[Appsignal::Rack::HanamiMiddleware, [], *hanami_middleware_options]
|
106
|
-
)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "when APPSIGNAL_APP_ENV ENV var is provided" do
|
111
|
-
it "uses this as the environment" do
|
112
|
-
ENV["APPSIGNAL_APP_ENV"] = "custom"
|
113
|
-
|
114
|
-
# Reset the plugin to pull down the latest data
|
115
|
-
Appsignal::Integrations::HanamiPlugin.init
|
116
|
-
|
117
|
-
expect(Appsignal.config.env).to eq("custom")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context "when APPSIGNAL_APP_ENV ENV var is not provided" do
|
122
|
-
it "uses the Hanami environment" do
|
123
|
-
# Reset the plugin to pull down the latest data
|
124
|
-
Appsignal::Integrations::HanamiPlugin.init
|
125
|
-
|
126
|
-
expect(Appsignal.config.env).to eq("test")
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
describe Appsignal::Integrations::HanamiIntegration do
|
132
|
-
let(:transaction) { http_request_transaction }
|
133
|
-
let(:app) do
|
134
|
-
Class.new(HanamiApp::Actions::Books::Index) do
|
135
|
-
def self.name
|
136
|
-
"HanamiApp::Actions::Books::Index::TestClass"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
around { |example| keep_transactions { example.run } }
|
141
|
-
before do
|
142
|
-
ENV["APPSIGNAL_APP_NAME"] = "hanamia-test-app"
|
143
|
-
ENV["APPSIGNAL_APP_ENV"] = "test"
|
144
|
-
ENV["APPSIGNAL_PUSH_API_KEY"] = "0000"
|
145
|
-
Appsignal::Integrations::HanamiPlugin.init
|
146
|
-
allow(app).to receive(:prepend).and_call_original
|
147
|
-
app.prepend(Appsignal::Integrations::HanamiIntegration)
|
148
|
-
end
|
149
|
-
|
150
|
-
def make_request(env)
|
151
|
-
action = app.new
|
152
|
-
action.call(env)
|
153
|
-
end
|
154
|
-
|
155
|
-
describe "#call" do
|
156
|
-
context "without an active transaction" do
|
157
|
-
let(:env) { {} }
|
158
|
-
|
159
|
-
it "does not set the action name" do
|
160
|
-
make_request(env)
|
161
|
-
|
162
|
-
expect(transaction).to_not have_action
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context "with an active transaction" do
|
167
|
-
let(:env) { { Appsignal::Rack::APPSIGNAL_TRANSACTION => transaction } }
|
168
|
-
|
169
|
-
it "sets action name on the transaction" do
|
170
|
-
make_request(env)
|
171
|
-
|
172
|
-
expect(transaction).to have_action("HanamiApp::Actions::Books::Index::TestClass")
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
9
|
+
require "appsignal/integrations/hanami"
|
177
10
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
[nil]
|
183
|
-
end
|
11
|
+
expect(Appsignal::Loaders.instances).to include(
|
12
|
+
:hanami => kind_of(Appsignal::Loaders::HanamiLoader)
|
13
|
+
)
|
14
|
+
expect(Appsignal.active?).to be(true)
|
184
15
|
end
|
185
16
|
end
|
186
17
|
end
|
@@ -3,8 +3,10 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
|
|
3
3
|
let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
|
4
4
|
|
5
5
|
context "with transaction" do
|
6
|
-
let
|
7
|
-
|
6
|
+
let(:transaction) { http_request_transaction }
|
7
|
+
before do
|
8
|
+
start_agent
|
9
|
+
set_current_transaction(transaction)
|
8
10
|
end
|
9
11
|
|
10
12
|
describe "#started" do
|
@@ -2,7 +2,7 @@ require "appsignal/integrations/net_http"
|
|
2
2
|
|
3
3
|
describe Appsignal::Integrations::NetHttpIntegration do
|
4
4
|
let(:transaction) { http_request_transaction }
|
5
|
-
before
|
5
|
+
before { start_agent }
|
6
6
|
before { set_current_transaction transaction }
|
7
7
|
around { |example| keep_transactions { example.run } }
|
8
8
|
|
@@ -29,7 +29,6 @@ describe Object do
|
|
29
29
|
start_agent
|
30
30
|
set_current_transaction(transaction)
|
31
31
|
end
|
32
|
-
after { Appsignal.config = nil }
|
33
32
|
|
34
33
|
context "with different kind of arguments" do
|
35
34
|
let(:klass) do
|
@@ -195,10 +194,9 @@ describe Object do
|
|
195
194
|
context "when active" do
|
196
195
|
let(:transaction) { http_request_transaction }
|
197
196
|
before do
|
198
|
-
|
197
|
+
start_agent
|
199
198
|
set_current_transaction(transaction)
|
200
199
|
end
|
201
|
-
after { Appsignal.config = nil }
|
202
200
|
|
203
201
|
context "with different kind of arguments" do
|
204
202
|
let(:klass) do
|
@@ -1,337 +1,15 @@
|
|
1
1
|
if DependencyHelper.padrino_present?
|
2
2
|
describe "Padrino integration" do
|
3
|
-
|
3
|
+
it "loads the Padrino loader" do
|
4
|
+
ENV["APPSIGNAL_APP_NAME"] = "test/sinatra"
|
5
|
+
ENV["APPSIGNAL_PUSH_API_KEY"] = "test-key"
|
4
6
|
|
5
|
-
|
6
|
-
let(:callbacks) { { :before_load => nil } }
|
7
|
-
before do
|
8
|
-
Appsignal.config = nil
|
9
|
-
allow(Padrino).to receive(:before_load)
|
10
|
-
.and_wrap_original do |original_method, *args, &block|
|
11
|
-
callbacks[:before_load] = block
|
12
|
-
original_method.call(*args, &block)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
after { uninstall_padrino_integration }
|
7
|
+
require "appsignal/integrations/padrino"
|
16
8
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
]
|
22
|
-
Padrino.middleware.delete_if do |middleware|
|
23
|
-
expected_middleware.include?(middleware.first)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when already active" do
|
28
|
-
before { allow(Appsignal).to receive(:active?).and_return(true) }
|
29
|
-
|
30
|
-
it "does not start AppSignal again" do
|
31
|
-
expect(Appsignal::Config).to_not receive(:new)
|
32
|
-
expect(Appsignal).to_not receive(:start)
|
33
|
-
|
34
|
-
Appsignal::Integrations::PadrinoPlugin.init
|
35
|
-
callbacks[:before_load].call
|
36
|
-
end
|
37
|
-
|
38
|
-
it "adds the instrumentation middleware to Sinatra::Base" do
|
39
|
-
Appsignal::Integrations::PadrinoPlugin.init
|
40
|
-
callbacks[:before_load].call
|
41
|
-
|
42
|
-
middlewares = Padrino.middleware
|
43
|
-
expect(middlewares).to include(
|
44
|
-
[Rack::Events, [[instance_of(Appsignal::Rack::EventHandler)]], nil]
|
45
|
-
)
|
46
|
-
expect(middlewares).to include(
|
47
|
-
[
|
48
|
-
Appsignal::Rack::SinatraBaseInstrumentation,
|
49
|
-
[
|
50
|
-
:instrument_event_name => "process_action.padrino"
|
51
|
-
],
|
52
|
-
nil
|
53
|
-
]
|
54
|
-
)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context "with active config" do
|
59
|
-
before do
|
60
|
-
ENV["APPSIGNAL_APP_NAME"] = "My Padrino app name"
|
61
|
-
ENV["APPSIGNAL_APP_ENV"] = "test"
|
62
|
-
ENV["APPSIGNAL_PUSH_API_KEY"] = "my-key"
|
63
|
-
end
|
64
|
-
|
65
|
-
it "starts AppSignal on init" do
|
66
|
-
expect(Appsignal).to_not be_active
|
67
|
-
|
68
|
-
Appsignal::Integrations::PadrinoPlugin.init
|
69
|
-
callbacks[:before_load].call
|
70
|
-
|
71
|
-
expect(Appsignal).to be_active
|
72
|
-
middlewares = Padrino.middleware
|
73
|
-
expect(middlewares).to include(
|
74
|
-
[Rack::Events, [[instance_of(Appsignal::Rack::EventHandler)]], nil]
|
75
|
-
)
|
76
|
-
expect(middlewares).to include(
|
77
|
-
[
|
78
|
-
Appsignal::Rack::SinatraBaseInstrumentation,
|
79
|
-
[
|
80
|
-
:instrument_event_name => "process_action.padrino"
|
81
|
-
],
|
82
|
-
nil
|
83
|
-
]
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
context "when APPSIGNAL_APP_ENV ENV var is provided" do
|
88
|
-
it "uses this as the environment" do
|
89
|
-
ENV["APPSIGNAL_APP_ENV"] = "custom"
|
90
|
-
|
91
|
-
Appsignal::Integrations::PadrinoPlugin.init
|
92
|
-
callbacks[:before_load].call
|
93
|
-
|
94
|
-
expect(Appsignal.config.env).to eq("custom")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context "when APPSIGNAL_APP_ENV ENV var is not provided" do
|
99
|
-
it "uses the Padrino environment" do
|
100
|
-
Appsignal::Integrations::PadrinoPlugin.init
|
101
|
-
callbacks[:before_load].call
|
102
|
-
|
103
|
-
expect(Padrino.env.to_s).to eq("test")
|
104
|
-
expect(Appsignal.config.env).to eq(Padrino.env.to_s)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context "when not active" do
|
110
|
-
it "does not add the listener middleware to the stack" do
|
111
|
-
expect(Appsignal).to_not be_active
|
112
|
-
|
113
|
-
Appsignal::Integrations::PadrinoPlugin.init
|
114
|
-
callbacks[:before_load].call
|
115
|
-
|
116
|
-
expect(Appsignal).to_not be_active
|
117
|
-
middlewares = Padrino.middleware
|
118
|
-
expect(middlewares).to_not include(
|
119
|
-
[Rack::Events, [[instance_of(Appsignal::Rack::EventHandler)]], nil]
|
120
|
-
)
|
121
|
-
expect(middlewares).to_not include(
|
122
|
-
[
|
123
|
-
Appsignal::Rack::SinatraBaseInstrumentation,
|
124
|
-
[
|
125
|
-
:request_class => ::Sinatra::Request,
|
126
|
-
:instrument_event_name => "process_action.padrino"
|
127
|
-
],
|
128
|
-
nil
|
129
|
-
]
|
130
|
-
)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe Padrino::Routing::InstanceMethods do
|
136
|
-
class PadrinoClassWithRouter
|
137
|
-
include Padrino::Routing
|
138
|
-
end
|
139
|
-
|
140
|
-
let(:base) { double }
|
141
|
-
let(:router) { PadrinoClassWithRouter.new }
|
142
|
-
let(:env) { {} }
|
143
|
-
# TODO: use an instance double
|
144
|
-
let(:settings) { double(:name => "TestApp") }
|
145
|
-
around { |example| keep_transactions { example.run } }
|
146
|
-
before { Appsignal.config = nil }
|
147
|
-
|
148
|
-
describe "routes" do
|
149
|
-
let(:env) do
|
150
|
-
{
|
151
|
-
"REQUEST_METHOD" => "GET",
|
152
|
-
"PATH_INFO" => path,
|
153
|
-
"REQUEST_PATH" => path,
|
154
|
-
"rack.input" => StringIO.new
|
155
|
-
}
|
156
|
-
end
|
157
|
-
let(:app) do
|
158
|
-
Class.new(Padrino::Application) do
|
159
|
-
def self.name
|
160
|
-
"PadrinoTestApp"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
let(:response) { app.call(env) }
|
165
|
-
|
166
|
-
RSpec::Matchers.define :match_response do |expected_status, expected_content|
|
167
|
-
match do |response|
|
168
|
-
status, _headers, content = response
|
169
|
-
matches_content =
|
170
|
-
if expected_content.is_a?(Regexp)
|
171
|
-
content.join =~ expected_content
|
172
|
-
else
|
173
|
-
content == [expected_content].compact
|
174
|
-
end
|
175
|
-
status == expected_status && matches_content
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context "when AppSignal is not active" do
|
180
|
-
let(:path) { "/foo" }
|
181
|
-
before { app.controllers { get(:foo) { "content" } } }
|
182
|
-
|
183
|
-
it "does not instrument the request" do
|
184
|
-
expect do
|
185
|
-
expect(response).to match_response(200, "content")
|
186
|
-
end.to_not(change { created_transactions.count })
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
context "when AppSignal is active" do
|
191
|
-
let(:transaction) { http_request_transaction }
|
192
|
-
before do
|
193
|
-
start_agent
|
194
|
-
set_current_transaction(transaction)
|
195
|
-
end
|
196
|
-
|
197
|
-
context "with not existing route" do
|
198
|
-
let(:path) { "/404" }
|
199
|
-
|
200
|
-
it "instruments the request" do
|
201
|
-
expect(response).to match_response(404, /^GET /404/)
|
202
|
-
expect(last_transaction).to have_action("PadrinoTestApp#unknown")
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
context "when Sinatra tells us it's a static file" do
|
207
|
-
let(:path) { "/static" }
|
208
|
-
before do
|
209
|
-
env["sinatra.static_file"] = true
|
210
|
-
app.controllers { get(:static) { "Static!" } }
|
211
|
-
end
|
212
|
-
|
213
|
-
it "does not instrument the request" do
|
214
|
-
expect(response).to match_response(200, "Static!")
|
215
|
-
expect(last_transaction).to_not have_action
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
# Older Padrino versions don't support `action` (v11.0+)
|
220
|
-
context "without #action on Sinatra::Request" do
|
221
|
-
let(:path) { "/my_original_path/10" }
|
222
|
-
before do
|
223
|
-
allow_any_instance_of(Sinatra::Request).to receive(:action).and_return(nil)
|
224
|
-
app.controllers { get(:my_original_path, :with => :id) { "content" } }
|
225
|
-
end
|
226
|
-
|
227
|
-
it "falls back on Sinatra::Request#route_obj.original_path" do
|
228
|
-
expect(response).to match_response(200, "content")
|
229
|
-
expect(last_transaction).to have_action("PadrinoTestApp:/my_original_path/:id")
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
context "without Sinatra::Request#route_obj.original_path" do
|
234
|
-
let(:path) { "/my_original_path" }
|
235
|
-
before do
|
236
|
-
allow_any_instance_of(Sinatra::Request).to receive(:action).and_return(nil)
|
237
|
-
allow_any_instance_of(Sinatra::Request).to receive(:route_obj).and_return(nil)
|
238
|
-
app.controllers { get(:my_original_path) { "content" } }
|
239
|
-
end
|
240
|
-
|
241
|
-
it "falls back on app name" do
|
242
|
-
expect(response).to match_response(200, "content")
|
243
|
-
expect(last_transaction).to have_action("PadrinoTestApp#unknown")
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
context "with existing route" do
|
248
|
-
let(:path) { "/" }
|
249
|
-
def make_request
|
250
|
-
expect(response).to match_response(200, "content")
|
251
|
-
end
|
252
|
-
|
253
|
-
context "with action name as symbol" do
|
254
|
-
context "with :index helper" do
|
255
|
-
before do
|
256
|
-
# :index == "/"
|
257
|
-
app.controllers { get(:index) { "content" } }
|
258
|
-
end
|
259
|
-
|
260
|
-
it "sets the action with the app name and action name" do
|
261
|
-
make_request
|
262
|
-
expect(last_transaction).to have_action("PadrinoTestApp:#index")
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
context "with custom action name" do
|
267
|
-
let(:path) { "/foo" }
|
268
|
-
before do
|
269
|
-
app.controllers { get(:foo) { "content" } }
|
270
|
-
end
|
271
|
-
|
272
|
-
it "sets the action with the app name and action name" do
|
273
|
-
make_request
|
274
|
-
expect(last_transaction).to have_action("PadrinoTestApp:#foo")
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
context "with an action defined with a path" do
|
280
|
-
context "with root path" do
|
281
|
-
before do
|
282
|
-
# :index == "/"
|
283
|
-
app.controllers { get("/") { "content" } }
|
284
|
-
end
|
285
|
-
|
286
|
-
it "sets the action with the app name and action path" do
|
287
|
-
make_request
|
288
|
-
expect(last_transaction).to have_action("PadrinoTestApp:#/")
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
context "with custom path" do
|
293
|
-
let(:path) { "/foo" }
|
294
|
-
before do
|
295
|
-
app.controllers { get("/foo") { "content" } }
|
296
|
-
end
|
297
|
-
|
298
|
-
it "sets the action with the app name and action path" do
|
299
|
-
make_request
|
300
|
-
expect(last_transaction).to have_action("PadrinoTestApp:#/foo")
|
301
|
-
end
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
context "with controller" do
|
306
|
-
let(:path) { "/my_controller" }
|
307
|
-
|
308
|
-
context "with controller as name" do
|
309
|
-
before do
|
310
|
-
# :index == "/"
|
311
|
-
app.controllers(:my_controller) { get(:index) { "content" } }
|
312
|
-
end
|
313
|
-
|
314
|
-
it "sets the action with the app name, controller name and action name" do
|
315
|
-
make_request
|
316
|
-
expect(last_transaction).to have_action("PadrinoTestApp:my_controller#index")
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
context "with controller as path" do
|
321
|
-
before do
|
322
|
-
# :index == "/"
|
323
|
-
app.controllers("/my_controller") { get(:index) { "content" } }
|
324
|
-
end
|
325
|
-
|
326
|
-
it "sets the action with the app name, controller name and action path" do
|
327
|
-
make_request
|
328
|
-
expect(last_transaction).to have_action("PadrinoTestApp:/my_controller#index")
|
329
|
-
end
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
end
|
334
|
-
end
|
9
|
+
expect(Appsignal::Loaders.instances).to include(
|
10
|
+
:padrino => kind_of(Appsignal::Loaders::PadrinoLoader)
|
11
|
+
)
|
12
|
+
expect(Appsignal.active?).to be(true)
|
335
13
|
end
|
336
14
|
end
|
337
15
|
end
|