Skip to content

Commit

Permalink
Merge pull request #686 from appsignal/remove-more-deprecations
Browse files Browse the repository at this point in the history
Remove more deprecations for 3.0
  • Loading branch information
tombruijn authored Jan 19, 2021
2 parents 89d5a9b + 5c2bcff commit 1cde9f9
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 604 deletions.
2 changes: 0 additions & 2 deletions lib/appsignal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,4 @@ def collect_environment_metadata
require "appsignal/transaction"
require "appsignal/version"
require "appsignal/rack/generic_instrumentation"
require "appsignal/rack/js_exception_catcher"
require "appsignal/js_exception_transaction"
require "appsignal/transmitter"
6 changes: 0 additions & 6 deletions lib/appsignal/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Config
:instrument_redis => true,
:instrument_sequel => true,
:skip_session_data => false,
:enable_frontend_error_catching => false,
:frontend_error_catching_path => "/appsignal_error_catcher",
:enable_allocation_tracking => true,
:enable_gc_instrumentation => false,
:enable_host_metrics => true,
Expand All @@ -49,15 +47,13 @@ class Config
"APPSIGNAL_PUSH_API_KEY" => :push_api_key,
"APPSIGNAL_APP_NAME" => :name,
"APPSIGNAL_PUSH_API_ENDPOINT" => :endpoint,
"APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH" => :frontend_error_catching_path,
"APPSIGNAL_DEBUG" => :debug,
"APPSIGNAL_LOG" => :log,
"APPSIGNAL_LOG_PATH" => :log_path,
"APPSIGNAL_INSTRUMENT_NET_HTTP" => :instrument_net_http,
"APPSIGNAL_INSTRUMENT_REDIS" => :instrument_redis,
"APPSIGNAL_INSTRUMENT_SEQUEL" => :instrument_sequel,
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
"APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING" => :enable_frontend_error_catching,
"APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
"APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
Expand Down Expand Up @@ -86,7 +82,6 @@ class Config
APPSIGNAL_APP_NAME
APPSIGNAL_CA_FILE_PATH
APPSIGNAL_DNS_SERVERS
APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH
APPSIGNAL_HOSTNAME
APPSIGNAL_HTTP_PROXY
APPSIGNAL_LOG
Expand All @@ -102,7 +97,6 @@ class Config
APPSIGNAL_ACTIVE
APPSIGNAL_DEBUG
APPSIGNAL_ENABLE_ALLOCATION_TRACKING
APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING
APPSIGNAL_ENABLE_GC_INSTRUMENTATION
APPSIGNAL_ENABLE_HOST_METRICS
APPSIGNAL_ENABLE_MINUTELY_PROBES
Expand Down
23 changes: 0 additions & 23 deletions lib/appsignal/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,6 @@ def truncate(text)
text.size > 200 ? "#{text[0...197]}..." : text
end
end

# Alias Probes constants that have moved to their own module in version
# 2.11.0.
def self.const_missing(name)
case name
when :SidekiqProbe
callers = caller
Appsignal::Utils::DeprecationMessage.message \
"The constant Appsignal::Hooks::SidekiqProbe has been deprecated. " \
"Please update the constant name to Appsignal::Probes::SidekiqProbe " \
"in the following file to remove this message.\n#{callers.first}"
Appsignal::Probes::SidekiqProbe
when :PumaProbe
callers = caller
Appsignal::Utils::DeprecationMessage.message \
"The constant Appsignal::Hooks::PumaProbe has been deprecated. " \
"Please update the constant name to Appsignal::Probes::PumaProbe " \
"in the following file to remove this message.\n#{callers.first}"
Appsignal::Probes::PumaProbe
else
super
end
end
end
end

Expand Down
5 changes: 1 addition & 4 deletions lib/appsignal/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ def self.initialize_appsignal(app)
)

if Appsignal.config[:enable_frontend_error_catching]
app.middleware.insert_before(
Appsignal::Rack::RailsInstrumentation,
Appsignal::Rack::JSExceptionCatcher
)
app.middleware.insert_before(Appsignal::Rack::RailsInstrumentation)
end

Appsignal.start
Expand Down
56 changes: 0 additions & 56 deletions lib/appsignal/js_exception_transaction.rb

This file was deleted.

12 changes: 0 additions & 12 deletions lib/appsignal/minutely.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
module Appsignal
class Minutely
class ProbeCollection
include Appsignal::Utils::DeprecationMessage

def initialize
@probes = {}
end
Expand All @@ -27,16 +25,6 @@ def [](key)
probes[key]
end

# @param probe [Object] Any object that listens to the `call` method will
# be used as a probe.
# @deprecated Use {#register} instead.
# @return [void]
def <<(probe)
deprecation_message "Deprecated `Appsignal::Minute.probes <<` " \
"call. Please use `Appsignal::Minutely.probes.register` instead."
register probe.object_id, probe
end

# Register a new minutely probe.
#
# Supported probe types are:
Expand Down
80 changes: 0 additions & 80 deletions lib/appsignal/rack/js_exception_catcher.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/lib/appsignal/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@
:push_api_key => "abc",
:name => "TestApp",
:active => true,
:enable_frontend_error_catching => false,
:frontend_error_catching_path => "/appsignal_error_catcher",
:enable_allocation_tracking => true,
:enable_gc_instrumentation => false,
:enable_host_metrics => true,
Expand Down
57 changes: 0 additions & 57 deletions spec/lib/appsignal/hooks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,63 +78,6 @@ def install
expect(Appsignal::Hooks.hooks[:mock_error_hook].installed?).to be_falsy
Appsignal::Hooks.hooks.delete(:mock_error_hook)
end

describe "missing constants" do
let(:err_stream) { std_stream }
let(:stderr) { err_stream.read }
let(:log_stream) { std_stream }
let(:log) { log_contents(log_stream) }
before do
Appsignal.logger = test_logger(log_stream)
end

def call_constant(&block)
capture_std_streams(std_stream, err_stream, &block)
end

describe "SidekiqProbe" do
it "logs a deprecation message and returns the new constant" do
constant = call_constant { Appsignal::Hooks::SidekiqProbe }

expect(constant).to eql(Appsignal::Probes::SidekiqProbe)
expect(constant.name).to eql("Appsignal::Probes::SidekiqProbe")

deprecation_message =
"The constant Appsignal::Hooks::SidekiqProbe has been deprecated. " \
"Please update the constant name to Appsignal::Probes::SidekiqProbe " \
"in the following file to remove this message.\n#{__FILE__}:"
expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
expect(log).to contains_log :warn, deprecation_message
end
end

describe "PumaProbe" do
it "logs a deprecation message and returns the new constant" do
constant = call_constant { Appsignal::Hooks::PumaProbe }

expect(constant).to eql(Appsignal::Probes::PumaProbe)
expect(constant.name).to eql("Appsignal::Probes::PumaProbe")

deprecation_message =
"The constant Appsignal::Hooks::PumaProbe has been deprecated. " \
"Please update the constant name to Appsignal::Probes::PumaProbe " \
"in the following file to remove this message.\n#{__FILE__}:"
expect(stderr).to include "appsignal WARNING: #{deprecation_message}"
expect(log).to contains_log :warn, deprecation_message
end
end

describe "other constant" do
it "raises a NameError like Ruby normally does" do
expect do
call_constant { Appsignal::Hooks::Unknown }
end.to raise_error(NameError)

expect(stderr).to be_empty
expect(log).to be_empty
end
end
end
end

describe Appsignal::Hooks::Helpers do
Expand Down
45 changes: 0 additions & 45 deletions spec/lib/appsignal/integrations/railtie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,51 +79,6 @@

after { Appsignal::Integrations::Railtie.initialize_appsignal(app) }
end

describe "frontend_error_catching middleware" do
let(:config) do
Appsignal::Config.new(
project_fixture_path,
"test",
:name => "MyApp",
:enable_frontend_error_catching => enable_frontend_error_catching
)
end
before { allow(Appsignal::Config).to receive(:new).and_return(config) }
after { Appsignal::Integrations::Railtie.initialize_appsignal(app) }

context "when enabled" do
let(:enable_frontend_error_catching) { true }

it "adds the Rails and JSExceptionCatcher middleware" do
expect(app.middleware).to receive(:insert_after).with(
ActionDispatch::DebugExceptions,
Appsignal::Rack::RailsInstrumentation
)

expect(app.middleware).to receive(:insert_before).with(
Appsignal::Rack::RailsInstrumentation,
Appsignal::Rack::JSExceptionCatcher
)
end
end

context "when not enabled" do
let(:enable_frontend_error_catching) { false }

it "adds the Rails middleware, but not the JSExceptionCatcher middleware" do
expect(app.middleware).to receive(:insert_after).with(
ActionDispatch::DebugExceptions,
Appsignal::Rack::RailsInstrumentation
)

expect(app.middleware).to_not receive(:insert_before).with(
Appsignal::Rack::RailsInstrumentation,
Appsignal::Rack::JSExceptionCatcher
)
end
end
end
end
end
end
Loading

0 comments on commit 1cde9f9

Please sign in to comment.