Skip to content

Commit

Permalink
Remove all deprecated components from gem
Browse files Browse the repository at this point in the history
Go through all the deprecated things listed in #667 and mentioned in the
source code itself.

Clean up before the next major version.
  • Loading branch information
tombruijn committed Jul 23, 2024
1 parent ba9b96e commit 801dee6
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 2,622 deletions.
6 changes: 6 additions & 0 deletions .changesets/remove-deprecated-components.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: major
type: remove
---

Remove all deprecated components. Please follow [our Ruby gem 4 upgrade guide](https://docs.appsignal.com/ruby/installation/upgrade-from-3-to-4.html) when upgrading to this version to avoid any errors from calling removed components, methods and helpers.
43 changes: 0 additions & 43 deletions lib/appsignal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@ class << self
# @see Config
attr_reader :config

# Set the AppSignal config.
#
# @deprecated Use {Appsignal.configure} instead.
# @param conf [Appsignal::Config]
# @return [void]
# @see Config
def config=(conf)
Appsignal::Utils::StdoutAndLoggerMessage.warning \
"Configuring AppSignal with `Appsignal.config=` is deprecated. " \
"Use `Appsignal.configure { |config| ... }` to configure AppSignal. " \
"https://docs.appsignal.com/ruby/configuration.html\n" \
"#{caller.first}"
@config = conf
end

# @api private
def _config=(conf)
@config = conf
Expand Down Expand Up @@ -333,18 +318,6 @@ def log_formatter(prefix = nil)
end
end

# @deprecated Only {.start} has to be called.
# @return [void]
# @since 0.7.0
def start_logger
callers = caller
Appsignal::Utils::StdoutAndLoggerMessage.warning \
"Calling 'Appsignal.start_logger' is deprecated. " \
"The logger will be started when calling 'Appsignal.start'. " \
"Remove the 'Appsignal.start_logger' call in the following file to " \
"remove this message.\n#{callers.first}"
end

# Start the AppSignal internal logger.
#
# Sets the log level and sets the logger. Uses a file-based logger or the
Expand Down Expand Up @@ -448,22 +421,6 @@ def collect_environment_metadata
end
Appsignal::Environment.report_supported_gems
end

# Alias constants that have moved with a warning message that points to the
# place to update the reference.
def const_missing(name)
case name
when :Minutely
callers = caller
Appsignal::Utils::StdoutAndLoggerMessage.warning \
"The constant Appsignal::Minutely has been deprecated. " \
"Please update the constant name to Appsignal::Probes " \
"in the following file to remove this message.\n#{callers.first}"
Appsignal::Probes
else
super
end
end
end
end

Expand Down
69 changes: 9 additions & 60 deletions lib/appsignal/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def self.add_loader_defaults(name, options)
DEFAULT_CONFIG = {
:activejob_report_errors => "all",
:ca_file_path => File.expand_path(File.join("../../../resources/cacert.pem"), __FILE__),
:debug => false,
:dns_servers => [],
:enable_allocation_tracking => true,
:enable_host_metrics => true,
Expand Down Expand Up @@ -59,8 +58,8 @@ def self.add_loader_defaults(name, options)
],
:send_environment_metadata => true,
:send_params => true,
:sidekiq_report_errors => "all",
:transaction_debug_mode => false
:send_session_data => true,
:sidekiq_report_errors => "all"
}.freeze

# @api private
Expand Down Expand Up @@ -96,13 +95,11 @@ def self.add_loader_defaults(name, options)
"APPSIGNAL_SIDEKIQ_REPORT_ERRORS" => :sidekiq_report_errors,
"APPSIGNAL_STATSD_PORT" => :statsd_port,
"APPSIGNAL_WORKING_DIRECTORY_PATH" => :working_directory_path,
"APPSIGNAL_WORKING_DIR_PATH" => :working_dir_path,
"APP_REVISION" => :revision
}.freeze
# @api private
ENV_BOOLEAN_KEYS = {
"APPSIGNAL_ACTIVE" => :active,
"APPSIGNAL_DEBUG" => :debug,
"APPSIGNAL_ENABLE_ALLOCATION_TRACKING" => :enable_allocation_tracking,
"APPSIGNAL_ENABLE_HOST_METRICS" => :enable_host_metrics,
"APPSIGNAL_ENABLE_MINUTELY_PROBES" => :enable_minutely_probes,
Expand All @@ -121,9 +118,7 @@ def self.add_loader_defaults(name, options)
"APPSIGNAL_RUNNING_IN_CONTAINER" => :running_in_container,
"APPSIGNAL_SEND_ENVIRONMENT_METADATA" => :send_environment_metadata,
"APPSIGNAL_SEND_PARAMS" => :send_params,
"APPSIGNAL_SEND_SESSION_DATA" => :send_session_data,
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
"APPSIGNAL_TRANSACTION_DEBUG_MODE" => :transaction_debug_mode
"APPSIGNAL_SEND_SESSION_DATA" => :send_session_data
}.freeze
# @api private
ENV_ARRAY_KEYS = {
Expand Down Expand Up @@ -274,9 +269,6 @@ def load_config
# Load config overrides
@override_config = determine_overrides
merge(override_config)

# Handle deprecated config options
maintain_backwards_compatibility
end

# @api private
Expand Down Expand Up @@ -306,12 +298,12 @@ def []=(key, value)

# @api private
def log_level
level = ::Logger::DEBUG if config_hash[:debug] || config_hash[:transaction_debug_mode]
option = config_hash[:log_level]
if option
log_level_option = LOG_LEVEL_MAP[option]
level = log_level_option if log_level_option
end
level =
if option
log_level_option = LOG_LEVEL_MAP[option]
log_level_option
end
level.nil? ? Appsignal::Config::DEFAULT_LOG_LEVEL : level
end

Expand Down Expand Up @@ -359,7 +351,6 @@ def write_to_environment # rubocop:disable Metrics/AbcSize
ENV["_APPSIGNAL_BIND_ADDRESS"] = config_hash[:bind_address].to_s
ENV["_APPSIGNAL_CA_FILE_PATH"] = config_hash[:ca_file_path].to_s
ENV["_APPSIGNAL_CPU_COUNT"] = config_hash[:cpu_count].to_s
ENV["_APPSIGNAL_DEBUG_LOGGING"] = config_hash[:debug].to_s
ENV["_APPSIGNAL_DNS_SERVERS"] = config_hash[:dns_servers].join(",")
ENV["_APPSIGNAL_ENABLE_HOST_METRICS"] = config_hash[:enable_host_metrics].to_s
ENV["_APPSIGNAL_ENABLE_STATSD"] = config_hash[:enable_statsd].to_s
Expand All @@ -386,13 +377,9 @@ def write_to_environment # rubocop:disable Metrics/AbcSize
ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"] = config_hash[:running_in_container].to_s
ENV["_APPSIGNAL_SEND_ENVIRONMENT_METADATA"] = config_hash[:send_environment_metadata].to_s
ENV["_APPSIGNAL_STATSD_PORT"] = config_hash[:statsd_port].to_s
ENV["_APPSIGNAL_TRANSACTION_DEBUG_MODE"] = config_hash[:transaction_debug_mode].to_s
if config_hash[:working_directory_path]
ENV["_APPSIGNAL_WORKING_DIRECTORY_PATH"] = config_hash[:working_directory_path]
end
if config_hash[:working_dir_path]
ENV["_APPSIGNAL_WORKING_DIR_PATH"] = config_hash[:working_dir_path]
end
ENV["_APP_REVISION"] = config_hash[:revision].to_s
end

Expand Down Expand Up @@ -476,27 +463,6 @@ def load_from_disk
nil
end

# Maintain backwards compatibility with deprecated config options.
#
# Add warnings for deprecated config options here if they have no
# replacement, or should be non-functional.
#
# Add them to {determine_overrides} if replacement config options should be
# set instead.
#
# Make sure to remove the contents of this method in the next major
# version, but the method itself with an empty body can stick around as a
# structure for future deprecations.
def maintain_backwards_compatibility
return unless config_hash.key?(:working_dir_path)

stdout_and_logger_warning \
"The `working_dir_path` option is deprecated, please use " \
"`working_directory_path` instead and specify the " \
"full path to the working directory",
logger
end

def load_from_environment
config = {}

Expand Down Expand Up @@ -536,11 +502,7 @@ def load_from_environment
end

# Set config options based on the final user config. Fix any conflicting
# config or set new config options based on deprecated config options.
#
# Make sure to remove behavior for deprecated config options in this method
# in the next major version, but the method itself with an empty body can
# stick around as a structure for future deprecations.
# config.
def determine_overrides
config = {}
# If an error was detected during config file reading/parsing and the new
Expand All @@ -549,19 +511,6 @@ def determine_overrides
# TODO: Make default behavior in next major version. Remove
# `inactive_on_config_file_error?` call.
config[:active] = false if @config_file_error && inactive_on_config_file_error?
skip_session_data = config_hash[:skip_session_data]
send_session_data = config_hash[:send_session_data]
if skip_session_data.nil? # Deprecated option is not set
if send_session_data.nil? # Not configured by user
config[:send_session_data] = true # Set default value
end
else
stdout_and_logger_warning "The `skip_session_data` config option is " \
"deprecated. Please use `send_session_data` instead.",
logger
# Not configured by user
config[:send_session_data] = !skip_session_data if send_session_data.nil?
end

if config_hash[:activejob_report_errors] == "discard" &&
!Appsignal::Hooks::ActiveJobHook.version_7_1_or_higher?
Expand Down
Loading

0 comments on commit 801dee6

Please sign in to comment.