Skip to content

Commit

Permalink
Merge pull request #428 from airbrake/deprecation-removals
Browse files Browse the repository at this point in the history
Remove deprecated functionality
  • Loading branch information
kyrylo authored Feb 21, 2019
2 parents 23a329b + 8773571 commit 17d6ced
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 110 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ Airbrake Ruby Changelog

### [v4.0.0][v4.0.0]

* Renamed `Airbrake.create_deploy` to `Airbrake.notify_deploy`
* Deleted deprecated `Airbrake.create_deploy`
* Deleted deprecated `Airbrake::Notifier` & `Airbrake::NilNotifier` constants
* Deleted deprecated `Config#route_stats`, `Config#route_stats_flush_period`
* `PerformanceNotifier`, `NoticeNotifier` & `DeployNotifier` stopped accepting
deprecated Hash as a `config` object

* Reduced clutter of `DeployNotifier` and `PerformanceNotifier` when
`inspect`ing ([#423](https://github.com/airbrake/airbrake-ruby/pull/423))
Expand Down
8 changes: 0 additions & 8 deletions lib/airbrake-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ def configured?
def merge_context(_context); end
end

# @deprecated Use {Airbrake::NoticeNotifier} instead
Notifier = NoticeNotifier
deprecate_constant(:Notifier) if respond_to?(:deprecate_constant)

# @deprecated Use {Airbrake::NilNoticeNotifier} instead
NilNotifier = NilNoticeNotifier
deprecate_constant(:NilNotifier) if respond_to?(:deprecate_constant)

# NilPerformanceNotifier is a no-op notifier, which mimics
# {Airbrake::PerformanceNotifier} and serves only the purpose of making the
# library API easier to use.
Expand Down
32 changes: 0 additions & 32 deletions lib/airbrake-ruby/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,38 +195,6 @@ def ignored_environment?
end
end

def route_stats
logger.warn(
"#{LOG_LABEL} the 'route_stats' option is deprecated. " \
"Use 'performance_stats' instead"
)
@performance_stats
end

def route_stats=(value)
logger.warn(
"#{LOG_LABEL} the 'route_stats' option is deprecated. " \
"Use 'performance_stats' instead"
)
@performance_stats = value
end

def route_stats_flush_period
logger.warn(
"#{LOG_LABEL} the 'route_stats_flush_period' option is deprecated. " \
"Use 'performance_stats_flush_period' instead"
)
@performance_stats_flush_period
end

def route_stats_flush_period=(value)
logger.warn(
"#{LOG_LABEL} the 'route_stats_flush_period' option is deprecated. " \
"Use 'performance_stats' instead"
)
@performance_stats_flush_period = value
end

private

def set_option(option, value)
Expand Down
16 changes: 2 additions & 14 deletions lib/airbrake-ruby/deploy_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@ class DeployNotifier

# @param [Airbrake::Config] config
def initialize(config)
@config =
if config.is_a?(Config)
config
else
loc = caller_locations(1..1).first
signature = "#{self.class.name}##{__method__}"
warn(
"#{loc.path}:#{loc.lineno}: warning: passing a Hash to #{signature} " \
'is deprecated. Pass `Airbrake::Config` instead'
)
Config.new(config)
end

@sender = SyncSender.new(@config)
@config = config
@sender = SyncSender.new(config)
end

# @see Airbrake.notify_deploy
Expand Down
29 changes: 3 additions & 26 deletions lib/airbrake-ruby/notice_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Airbrake
# @see Airbrake::Config The list of options
# @since v1.0.0
# @api public
# rubocop:disable Metrics/ClassLength
class NoticeNotifier
# @return [Array<Class>] filters to be executed first
DEFAULT_FILTERS = [
Expand All @@ -28,23 +27,11 @@ class NoticeNotifier
#
# @param [Airbrake::Config] config
def initialize(config, perf_notifier = nil)
@config =
if config.is_a?(Config)
config
else
loc = caller_locations(1..1).first
signature = "#{self.class.name}##{__method__}"
warn(
"#{loc.path}:#{loc.lineno}: warning: passing a Hash to #{signature} " \
'is deprecated. Pass `Airbrake::Config` instead'
)
Config.new(config)
end

@config = config
@context = {}
@filter_chain = FilterChain.new
@async_sender = AsyncSender.new(@config)
@sync_sender = SyncSender.new(@config)
@async_sender = AsyncSender.new(config)
@sync_sender = SyncSender.new(config)
@perf_notifier = perf_notifier

add_default_filters
Expand All @@ -60,15 +47,6 @@ def notify_sync(exception, params = {}, &block)
send_notice(exception, params, @sync_sender, &block).value
end

# @deprecated Update the airbrake gem to v8.1.0 or higher
def notify_request(request_info, promise = Promise.new)
@config.logger.info(
"#{LOG_LABEL} #{self.class}##{__method__} is deprecated. Update " \
'the airbrake gem to v8.1.0 or higher'
)
@perf_notifier.notify(Request.new(request_info), promise)
end

# @macro see_public_api_method
def add_filter(filter = nil, &block)
@filter_chain.add_filter(block_given? ? block : filter)
Expand Down Expand Up @@ -194,5 +172,4 @@ def add_default_filters
end
# rubocop:enable Metrics/AbcSize
end
# rubocop:enable Metrics/ClassLength
end
18 changes: 3 additions & 15 deletions lib/airbrake-ruby/performance_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,9 @@ class PerformanceNotifier

# @param [Airbrake::Config] config
def initialize(config)
@config =
if config.is_a?(Config)
config
else
loc = caller_locations(1..1).first
signature = "#{self.class.name}##{__method__}"
warn(
"#{loc.path}:#{loc.lineno}: warning: passing a Hash to #{signature} " \
'is deprecated. Pass `Airbrake::Config` instead'
)
Config.new(config)
end

@flush_period = @config.performance_stats_flush_period
@sender = SyncSender.new(@config, :put)
@config = config
@flush_period = config.performance_stats_flush_period
@sender = SyncSender.new(config, :put)
@payload = {}
@schedule_flush = nil
@mutex = Mutex.new
Expand Down
14 changes: 0 additions & 14 deletions spec/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,10 @@
expect(config.whitelist_keys).to be_empty
end

it "disables route stats by default (deprecated)" do
out = StringIO.new
config.logger = Logger.new(out)
expect(config.route_stats).to be_falsey
expect(out.string).to match(/'route_stats'.+is deprecated/)
end

it "disables performance stats by default" do
expect(config.performance_stats).to be_falsey
end

it "sets the default route_stats_flush_period (deprecated)" do
out = StringIO.new
config.logger = Logger.new(out)
expect(config.route_stats_flush_period).to eq(15)
expect(out.string).to match(/'route_stats_flush_period'.+is deprecated/)
end

it "sets the default performance_stats_flush_period" do
expect(config.performance_stats_flush_period).to eq(15)
end
Expand Down

0 comments on commit 17d6ced

Please sign in to comment.