From 7f9fe1c99be9f98289c2bb1fb286c2592a3b58a3 Mon Sep 17 00:00:00 2001 From: Neel Shah Date: Fri, 26 Sep 2025 15:19:31 +0200 Subject: [PATCH] Remove deprecated Sentry::Rails::Tracing::ActionControllerSubscriber --- CHANGELOG.md | 1 + .../lib/sentry/rails/configuration.rb | 1 - .../instrument_payload_cleanup_helper.rb | 15 ----- .../tracing/action_controller_subscriber.rb | 43 ------------ .../action_controller_subscriber_spec.rb | 65 ------------------- 5 files changed, 1 insertion(+), 124 deletions(-) delete mode 100644 sentry-rails/lib/sentry/rails/instrument_payload_cleanup_helper.rb delete mode 100644 sentry-rails/lib/sentry/rails/tracing/action_controller_subscriber.rb delete mode 100644 sentry-rails/spec/sentry/rails/tracing/action_controller_subscriber_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 9448253a8..190260ee7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - 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)) ### Features 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/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