-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate StreamingListener middleware
Deprecate the StreamingListener now that it is almost identical to the AbstractMiddleware. Those couple differences are actually ones we don't want people to rely on, so deprecate it.
- Loading branch information
Showing
3 changed files
with
69 additions
and
21 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
.changesets/deprecate-appsignal--rack--streaminglistener-middleware.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
bump: patch | ||
type: deprecate | ||
--- | ||
|
||
Deprecate the `Appsignal::Rack::StreamingListener` middleware. Use the `Appsignal::Rack::InstrumentationMiddleware` middleware instead. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,69 @@ | ||
require "appsignal/rack/streaming_listener" | ||
describe "Appsignal::Rack::StreamingListener" do | ||
def load_middleware | ||
load "lib/appsignal/rack/streaming_listener.rb" | ||
end | ||
|
||
describe Appsignal::Rack::StreamingListener do | ||
let(:env) { {} } | ||
let(:app) { DummyApp.new } | ||
let(:middleware) { described_class.new(app, {}) } | ||
before { start_agent } | ||
around { |example| keep_transactions { example.run } } | ||
describe "loading the streaming_listener integrations file" do | ||
let(:err_stream) { std_stream } | ||
let(:stderr) { err_stream.read } | ||
after { Appsignal::Rack.send(:remove_const, :StreamingListener) } | ||
|
||
def make_request | ||
middleware.call(env) | ||
end | ||
it "prints a deprecation warning to STDERR" do | ||
capture_std_streams(std_stream, err_stream) do | ||
load_middleware | ||
end | ||
|
||
it "instruments the call" do | ||
make_request | ||
expect(stderr).to include( | ||
"appsignal WARNING: The constant Appsignal::Rack::StreamingListener " \ | ||
"has been deprecated." | ||
) | ||
end | ||
|
||
expect(last_transaction).to include_event("name" => "process_streaming_request.rack") | ||
it "logs a warning" do | ||
logs = | ||
capture_logs do | ||
silence do | ||
load_middleware | ||
end | ||
end | ||
|
||
expect(logs).to contains_log( | ||
:warn, | ||
"The constant Appsignal::Rack::StreamingListener has been deprecated." | ||
) | ||
end | ||
end | ||
|
||
it "set no action by default" do | ||
make_request | ||
describe "middleware" do | ||
let(:env) { {} } | ||
let(:app) { DummyApp.new } | ||
let(:middleware) { Appsignal::Rack::StreamingListener.new(app, {}) } | ||
around { |example| keep_transactions { example.run } } | ||
before(:context) { load_middleware } | ||
before { start_agent } | ||
|
||
expect(last_transaction).to_not have_action | ||
end | ||
def make_request | ||
middleware.call(env) | ||
end | ||
|
||
it "instruments the call" do | ||
make_request | ||
|
||
expect(last_transaction).to include_event("name" => "process_streaming_request.rack") | ||
end | ||
|
||
it "set no action by default" do | ||
make_request | ||
|
||
expect(last_transaction).to_not have_action | ||
end | ||
|
||
it "set `appsignal.action` to the action name" do | ||
env["appsignal.action"] = "Action" | ||
it "set `appsignal.action` to the action name" do | ||
env["appsignal.action"] = "Action" | ||
|
||
make_request | ||
make_request | ||
|
||
expect(last_transaction).to have_action("Action") | ||
expect(last_transaction).to have_action("Action") | ||
end | ||
end | ||
end |