diff --git a/CHANGELOG.md b/CHANGELOG.md index 30d26ab71..a52fc6cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,19 @@ ### Breaking Changes -- Remove `config.async` [#1894](https://github.com/getsentry/sentry-ruby/pull/1894) +- Remove deprecated `config.async` [#1894](https://github.com/getsentry/sentry-ruby/pull/1894) +- Remove deprecated `Sentry::Metrics` and `config.metrics` and all metrics related code ([#2729](https://github.com/getsentry/sentry-ruby/pull/2729)) +- Remove deprecated `config.capture_exception_frame_locals`, use `include_local_variables` instead ([#2730](https://github.com/getsentry/sentry-ruby/pull/2730)) +- Remove deprecated `config.enable_tracing`, use `config.traces_sample_rate = 1.0` instead ([#2731](https://github.com/getsentry/sentry-ruby/pull/2731)) +- Remove deprecated `config.logger=`, use `config.sdk_logger=` instead ([#2732](https://github.com/getsentry/sentry-ruby/pull/2732)) +- Remove deprecated `Sentry::Rails::Tracing::ActionControllerSubscriber` ([#2733](https://github.com/getsentry/sentry-ruby/pull/2733)) +- Remove `:monotonic_active_support_logger` from `config.breadcrumbs_logger` ([#2717](https://github.com/getsentry/sentry-ruby/pull/2717)) - Migrate from to_hash to to_h ([#2351](https://github.com/getsentry/sentry-ruby/pull/2351)) - Add `before_send_check_in` for applying to `CheckInEvent` ([#2703](https://github.com/getsentry/sentry-ruby/pull/2703)) - Returning a hash from `before_send` and `before_send_transaction` is no longer supported and will drop the event. - Remove stacktrace trimming ([#2714](https://github.com/getsentry/sentry-ruby/pull/2714)) - `config.enabled_environments` now defaults to `nil` instead of `[]` for sending to all environments ([#2716](https://github.com/getsentry/sentry-ruby/pull/2716)) -- Remove `:monotonic_active_support_logger` from `config.breadcrumbs_logger` ([#2717](https://github.com/getsentry/sentry-ruby/pull/2717)) - Requests which have response status codes in the inclusive ranges `[(301..303), (305..399), (401..404)]` will no longer create transactions by default. See `config.trace_ignore_status_codes` below to control what gets traced. -- Remove `Sentry::Metrics` and `config.metrics` and all metrics related code ([#2729](https://github.com/getsentry/sentry-ruby/pull/2729)) ### Features diff --git a/sentry-rails/benchmarks/allocation_comparison.rb b/sentry-rails/benchmarks/allocation_comparison.rb index 15b1e3c4a..4e96eda35 100644 --- a/sentry-rails/benchmarks/allocation_comparison.rb +++ b/sentry-rails/benchmarks/allocation_comparison.rb @@ -11,7 +11,7 @@ end app = create_app do |config| - config.logger = ::Logger.new(STDOUT) + config.sdk_logger = ::Logger.new(STDOUT) config.transport.transport_class = Sentry::BenchmarkTransport config.breadcrumbs_logger = [:active_support_logger] end diff --git a/sentry-rails/benchmarks/allocation_report.rb b/sentry-rails/benchmarks/allocation_report.rb index 9bc691a26..6e0bc1d02 100644 --- a/sentry-rails/benchmarks/allocation_report.rb +++ b/sentry-rails/benchmarks/allocation_report.rb @@ -11,7 +11,7 @@ end app = create_app do |config| - config.logger = ::Logger.new(STDOUT) + config.sdk_logger = ::Logger.new(STDOUT) config.transport.transport_class = Sentry::BenchmarkTransport config.breadcrumbs_logger = [:active_support_logger] end diff --git a/sentry-rails/examples/minimum-rails/app.rb b/sentry-rails/examples/minimum-rails/app.rb index e100e5395..92bab5647 100644 --- a/sentry-rails/examples/minimum-rails/app.rb +++ b/sentry-rails/examples/minimum-rails/app.rb @@ -15,7 +15,7 @@ Sentry.init do |config| config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472' - config.logger = Logger.new($stdout) + config.sdk_logger = Logger.new($stdout) end ActiveSupport::Deprecation.silenced = true diff --git a/sentry-rails/examples/rails-6.0/config/initializers/sentry.rb b/sentry-rails/examples/rails-6.0/config/initializers/sentry.rb index c0b0d08fb..70cb1aa18 100644 --- a/sentry-rails/examples/rails-6.0/config/initializers/sentry.rb +++ b/sentry-rails/examples/rails-6.0/config/initializers/sentry.rb @@ -5,7 +5,7 @@ config.traces_sample_rate = 1.0 # set a float between 0.0 and 1.0 to enable performance monitoring config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472' config.release = `git branch --show-current` - config.capture_exception_frame_locals = true + config.include_local_variables = true # you can use the pre-defined job for the async callback # # config.async = lambda do |event, hint| diff --git a/sentry-rails/examples/rails-7.0/config/initializers/sentry.rb b/sentry-rails/examples/rails-7.0/config/initializers/sentry.rb index c0b0d08fb..70cb1aa18 100644 --- a/sentry-rails/examples/rails-7.0/config/initializers/sentry.rb +++ b/sentry-rails/examples/rails-7.0/config/initializers/sentry.rb @@ -5,7 +5,7 @@ config.traces_sample_rate = 1.0 # set a float between 0.0 and 1.0 to enable performance monitoring config.dsn = 'https://2fb45f003d054a7ea47feb45898f7649@o447951.ingest.sentry.io/5434472' config.release = `git branch --show-current` - config.capture_exception_frame_locals = true + config.include_local_variables = true # you can use the pre-defined job for the async callback # # config.async = lambda do |event, hint| diff --git a/sentry-rails/lib/sentry/rails/configuration.rb b/sentry-rails/lib/sentry/rails/configuration.rb index 7b27a9152..42306e07f 100644 --- a/sentry-rails/lib/sentry/rails/configuration.rb +++ b/sentry-rails/lib/sentry/rails/configuration.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -require "sentry/rails/tracing/action_controller_subscriber" require "sentry/rails/tracing/action_view_subscriber" require "sentry/rails/tracing/active_record_subscriber" require "sentry/rails/tracing/active_storage_subscriber" diff --git a/sentry-rails/lib/sentry/rails/instrument_payload_cleanup_helper.rb b/sentry-rails/lib/sentry/rails/instrument_payload_cleanup_helper.rb deleted file mode 100644 index 07422c5e8..000000000 --- a/sentry-rails/lib/sentry/rails/instrument_payload_cleanup_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module Sentry - module Rails - module InstrumentPayloadCleanupHelper - IGNORED_DATA_TYPES = [:request, :response, :headers, :exception, :exception_object, Tracing::START_TIMESTAMP_NAME] - - def cleanup_data(data) - IGNORED_DATA_TYPES.each do |key| - data.delete(key) if data.key?(key) - end - end - end - end -end diff --git a/sentry-rails/lib/sentry/rails/tracing/action_controller_subscriber.rb b/sentry-rails/lib/sentry/rails/tracing/action_controller_subscriber.rb deleted file mode 100644 index 996332bb5..000000000 --- a/sentry-rails/lib/sentry/rails/tracing/action_controller_subscriber.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require "sentry/rails/tracing/abstract_subscriber" -require "sentry/rails/instrument_payload_cleanup_helper" - -module Sentry - module Rails - module Tracing - class ActionControllerSubscriber < AbstractSubscriber - extend InstrumentPayloadCleanupHelper - - EVENT_NAMES = ["process_action.action_controller"].freeze - OP_NAME = "view.process_action.action_controller" - SPAN_ORIGIN = "auto.view.rails" - - def self.subscribe! - Sentry.sdk_logger.warn <<~MSG - DEPRECATION WARNING: sentry-rails has changed its approach on controller span recording and #{self.name} is now depreacted. - Please stop using or referencing #{self.name} as it will be removed in the next major release. - MSG - - subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload| - controller = payload[:controller] - action = payload[:action] - - record_on_current_span( - op: OP_NAME, - origin: SPAN_ORIGIN, - start_timestamp: payload[START_TIMESTAMP_NAME], - description: "#{controller}##{action}", - duration: duration - ) do |span| - payload = payload.dup - cleanup_data(payload) - span.set_data(:payload, payload) - span.set_http_status(payload[:status]) - end - end - end - end - end - end -end diff --git a/sentry-rails/spec/dummy/test_rails_app/app.rb b/sentry-rails/spec/dummy/test_rails_app/app.rb index 42f4d8d04..85eadf39b 100644 --- a/sentry-rails/spec/dummy/test_rails_app/app.rb +++ b/sentry-rails/spec/dummy/test_rails_app/app.rb @@ -105,7 +105,7 @@ def self.name config.transport.transport_class = Sentry::DummyTransport # for sending events synchronously config.background_worker_threads = 0 - config.capture_exception_frame_locals = true + config.include_local_variables = true yield(config, app) if block_given? end end diff --git a/sentry-rails/spec/sentry/rails/tracing/action_controller_subscriber_spec.rb b/sentry-rails/spec/sentry/rails/tracing/action_controller_subscriber_spec.rb deleted file mode 100644 index b36b05b18..000000000 --- a/sentry-rails/spec/sentry/rails/tracing/action_controller_subscriber_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe Sentry::Rails::Tracing::ActionControllerSubscriber, :subscriber, type: :request do - let(:transport) do - Sentry.get_current_client.transport - end - - context "when transaction is sampled" do - let(:string_io) { StringIO.new } - let(:logger) do - ::Logger.new(string_io) - end - - before do - make_basic_app do |config| - config.traces_sample_rate = 1.0 - config.rails.tracing_subscribers = [described_class] - config.sdk_logger = logger - end - end - - it "logs deprecation message" do - expect(string_io.string).to include( - "DEPRECATION WARNING: sentry-rails has changed its approach on controller span recording and Sentry::Rails::Tracing::ActionControllerSubscriber is now depreacted." - ) - end - - it "records controller action processing event" do - get "/world" - - expect(transport.events.count).to eq(1) - - transaction = transport.events.first.to_h - expect(transaction[:type]).to eq("transaction") - expect(transaction[:spans].count).to eq(2) - - span = transaction[:spans][0] - expect(span[:op]).to eq("view.process_action.action_controller") - expect(span[:origin]).to eq("auto.view.rails") - expect(span[:description]).to eq("HelloController#world") - expect(span[:trace_id]).to eq(transaction.dig(:contexts, :trace, :trace_id)) - expect(span[:data].keys).to match_array(["http.response.status_code", :format, :method, :path, :params]) - end - end - - context "when transaction is not sampled" do - before do - make_basic_app - end - - it "doesn't record spans" do - transaction = Sentry::Transaction.new(sampled: false, hub: Sentry.get_current_hub) - Sentry.get_current_scope.set_span(transaction) - - get "/world" - - transaction.finish - - expect(transport.events.count).to eq(0) - expect(transaction.span_recorder.spans).to eq([transaction]) - end - end -end diff --git a/sentry-ruby/benchmarks/allocation_comparison.rb b/sentry-ruby/benchmarks/allocation_comparison.rb index c765b2ff6..9a3b87bd9 100644 --- a/sentry-ruby/benchmarks/allocation_comparison.rb +++ b/sentry-ruby/benchmarks/allocation_comparison.rb @@ -5,7 +5,7 @@ require "sentry/benchmarks/benchmark_transport" Sentry.init do |config| - config.logger = ::Logger.new(nil) + config.sdk_logger = ::Logger.new(nil) config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42" config.transport.transport_class = Sentry::BenchmarkTransport config.breadcrumbs_logger = [:sentry_logger] diff --git a/sentry-ruby/benchmarks/allocation_report.rb b/sentry-ruby/benchmarks/allocation_report.rb index 54fbd4139..36d7ece57 100644 --- a/sentry-ruby/benchmarks/allocation_report.rb +++ b/sentry-ruby/benchmarks/allocation_report.rb @@ -5,7 +5,7 @@ require "sentry/benchmarks/benchmark_transport" Sentry.init do |config| - config.logger = ::Logger.new(nil) + config.sdk_logger = ::Logger.new(nil) config.dsn = "dummy://12345:67890@sentry.localdomain:3000/sentry/42" config.transport.transport_class = Sentry::BenchmarkTransport config.breadcrumbs_logger = [:sentry_logger] diff --git a/sentry-ruby/lib/sentry/configuration.rb b/sentry-ruby/lib/sentry/configuration.rb index c72ca1561..587e71619 100644 --- a/sentry-ruby/lib/sentry/configuration.rb +++ b/sentry-ruby/lib/sentry/configuration.rb @@ -176,18 +176,6 @@ class Configuration # @return [Boolean, String] attr_accessor :spotlight - # @deprecated Use {#include_local_variables} instead. - alias_method :capture_exception_frame_locals, :include_local_variables - - # @deprecated Use {#include_local_variables=} instead. - def capture_exception_frame_locals=(value) - log_warn <<~MSG - `capture_exception_frame_locals` is now deprecated in favor of `include_local_variables`. - MSG - - self.include_local_variables = value - end - # You may provide your own LineCache for matching paths with source files. # This may be useful if you need to get source code from places other than the disk. # @see LineCache @@ -204,18 +192,6 @@ def capture_exception_frame_locals=(value) # @return [String, nil] attr_accessor :sdk_debug_transport_log_file - # @deprecated Use {#sdk_logger=} instead. - def logger=(logger) - warn "[sentry] `config.logger=` is deprecated. Please use `config.sdk_logger=` instead." - self.sdk_logger = logger - end - - # @deprecated Use {#sdk_logger} instead. - def logger - warn "[sentry] `config.logger` is deprecated. Please use `config.sdk_logger` instead." - self.sdk_logger - end - # Project directory root for in_app detection. Could be Rails root, etc. # Set automatically for Rails. # @return [String] @@ -297,12 +273,6 @@ def logger # @return [StructuredLoggingConfiguration] attr_reader :structured_logging - # Easier way to use performance tracing - # If set to true, will set traces_sample_rate to 1.0 - # @deprecated It will be removed in the next major release. - # @return [Boolean, nil] - attr_reader :enable_tracing - # Send diagnostic client reports about dropped events, true by default # tries to attach to an existing envelope max once every 30s # @return [Boolean] @@ -519,7 +489,6 @@ def initialize self.before_send_log = nil self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT self.traces_sampler = nil - self.enable_tracing = nil self.enable_logs = false self.profiler_class = Sentry::Profiler @@ -621,17 +590,6 @@ def trace_ignore_status_codes=(codes) @trace_ignore_status_codes = codes end - def enable_tracing=(enable_tracing) - unless enable_tracing.nil? - log_warn <<~MSG - `enable_tracing` is now deprecated in favor of `traces_sample_rate = 1.0`. - MSG - end - - @enable_tracing = enable_tracing - @traces_sample_rate ||= 1.0 if enable_tracing - end - def traces_sample_rate=(traces_sample_rate) @traces_sample_rate = traces_sample_rate end @@ -696,7 +654,7 @@ def valid_sample_rate?(sample_rate) def tracing_enabled? valid_sampler = !!((valid_sample_rate?(@traces_sample_rate)) || @traces_sampler) - (@enable_tracing != false) && valid_sampler && sending_allowed? + valid_sampler && sending_allowed? end def profiling_enabled? diff --git a/sentry-ruby/spec/sentry/configuration_spec.rb b/sentry-ruby/spec/sentry/configuration_spec.rb index faf3f7735..e6d94146c 100644 --- a/sentry-ruby/spec/sentry/configuration_spec.rb +++ b/sentry-ruby/spec/sentry/configuration_spec.rb @@ -1,29 +1,6 @@ # frozen_string_literal: true RSpec.describe Sentry::Configuration do - describe "#capture_exception_frame_locals" do - it "passes/received the value to #include_local_variables" do - subject.capture_exception_frame_locals = true - expect(subject.include_local_variables).to eq(true) - expect(subject.capture_exception_frame_locals).to eq(true) - - subject.capture_exception_frame_locals = false - expect(subject.include_local_variables).to eq(false) - expect(subject.capture_exception_frame_locals).to eq(false) - end - - it "prints deprecation message when being assigned" do - string_io = StringIO.new - subject.logger = Logger.new(string_io) - - subject.capture_exception_frame_locals = true - - expect(string_io.string).to include( - "WARN -- sentry: `capture_exception_frame_locals` is now deprecated in favor of `include_local_variables`." - ) - end - end - describe "#background_worker_threads" do it "sets to have of the processors count" do allow_any_instance_of(Sentry::Configuration).to receive(:processor_count).and_return(8) @@ -114,25 +91,6 @@ expect(subject.tracing_enabled?).to eq(false) end end - - context "when enable_tracing is set" do - it "returns false" do - subject.enable_tracing = true - - expect(subject.tracing_enabled?).to eq(false) - end - - it "prints deprecation message when being assigned" do - string_io = StringIO.new - subject.logger = Logger.new(string_io) - - subject.enable_tracing = true - - expect(string_io.string).to include( - "WARN -- sentry: `enable_tracing` is now deprecated in favor of `traces_sample_rate = 1.0`." - ) - end - end end context "when sending allowed" do @@ -175,29 +133,6 @@ expect(subject.tracing_enabled?).to eq(true) end end - - context "when enable_tracing is true" do - it "returns true" do - subject.enable_tracing = true - - expect(subject.tracing_enabled?).to eq(true) - end - end - - context "when enable_tracing is false" do - it "returns false" do - subject.enable_tracing = false - - expect(subject.tracing_enabled?).to eq(false) - end - - it "returns false even with explicit traces_sample_rate" do - subject.traces_sample_rate = 1.0 - subject.enable_tracing = false - - expect(subject.tracing_enabled?).to eq(false) - end - end end end @@ -227,19 +162,19 @@ describe "#profiling_enabled?" do it "returns false unless tracing enabled" do - subject.enable_tracing = false + subject.traces_sample_rate = nil expect(subject.profiling_enabled?).to eq(false) end it "returns false unless sending enabled" do - subject.enable_tracing = true + subject.traces_sample_rate = 1.0 subject.profiles_sample_rate = 1.0 allow(subject).to receive(:sending_allowed?).and_return(false) expect(subject.profiling_enabled?).to eq(false) end context 'when tracing and sending enabled' do - before { subject.enable_tracing = true } + before { subject.traces_sample_rate = 1.0 } before { allow(subject).to receive(:sending_allowed?).and_return(true) } it "returns false if nil sample rate" do @@ -259,19 +194,6 @@ end end - describe "#enable_tracing=" do - it "sets traces_sample_rate to 1.0 automatically" do - subject.enable_tracing = true - expect(subject.traces_sample_rate).to eq(1.0) - end - - it "doesn't override existing traces_sample_rate" do - subject.traces_sample_rate = 0.5 - subject.enable_tracing = true - expect(subject.traces_sample_rate).to eq(0.5) - end - end - describe "#transport" do it "returns an initialized Transport::Configuration object" do transport_config = subject.transport @@ -790,22 +712,6 @@ class SentryConfigurationSample < Sentry::Configuration end end - describe "#logger" do - it "returns configured sdk_logger and prints deprecation warning" do - expect { - expect(subject.logger).to be(subject.sdk_logger) - }.to output(/`config.logger` is deprecated/).to_stderr - end - end - - describe "#logger=" do - it "sets sdk_logger and prints deprecation warning" do - expect { - subject.logger = Logger.new($stdout) - }.to output(/`config.logger=` is deprecated/).to_stderr - end - end - describe "#trace_ignore_status_codes" do it "has default values" do expect(subject.trace_ignore_status_codes).to eq([(301..303), (305..399), (401..404)])