diff --git a/sentry-rails/lib/sentry/rails/configuration.rb b/sentry-rails/lib/sentry/rails/configuration.rb index 1def9aee6..29eea220a 100644 --- a/sentry-rails/lib/sentry/rails/configuration.rb +++ b/sentry-rails/lib/sentry/rails/configuration.rb @@ -141,6 +141,8 @@ class Configuration # ``` attr_accessor :assets_regexp + # Hash of subscription items that will be shown in breadcrumbs active support logger. + # @return [Hash>] attr_accessor :active_support_logger_subscription_items def initialize diff --git a/sentry-rails/spec/sentry/rails/breadcrumbs/active_support_logger_spec.rb b/sentry-rails/spec/sentry/rails/breadcrumbs/active_support_logger_spec.rb index 84b7c7cd8..c324bc4df 100644 --- a/sentry-rails/spec/sentry/rails/breadcrumbs/active_support_logger_spec.rb +++ b/sentry-rails/spec/sentry/rails/breadcrumbs/active_support_logger_spec.rb @@ -66,25 +66,28 @@ expect(breadcrumb_buffer.count).to be_zero end - it "breadcrumb data only contains parameters setted by rails config" do - Sentry.configuration.rails.active_support_logger_subscription_items["process_action.action_controller"].delete(:controller) - - get "/exception" - - breadcrumbs = event.dig("breadcrumbs", "values") - breadcrumb = breadcrumbs.detect { |b| b["category"] == "process_action.action_controller" } - - expect(breadcrumb["data"]).to include( - { - "action" => "exception", - "params" => { "controller" => "hello", "action" => "exception" }, - "format" => "html", - "method" => "GET", "path" => "/exception", - } - ) - expect(breadcrumb["data"].keys).not_to include("controller") - - Sentry.configuration.rails.active_support_logger_subscription_items["process_action.action_controller"] << :controller + context "with modified items" do + before { Sentry.configuration.rails.active_support_logger_subscription_items["process_action.action_controller"].delete(:controller) } + after { Sentry.configuration.rails.active_support_logger_subscription_items["process_action.action_controller"] << :controller } + + it "breadcrumb data only contains parameters setted by rails config" do + Sentry.configuration.rails.active_support_logger_subscription_items["process_action.action_controller"].delete(:controller) + + get "/exception" + + breadcrumbs = event.dig("breadcrumbs", "values") + breadcrumb = breadcrumbs.detect { |b| b["category"] == "process_action.action_controller" } + + expect(breadcrumb["data"]).to include( + { + "action" => "exception", + "params" => { "controller" => "hello", "action" => "exception" }, + "format" => "html", + "method" => "GET", "path" => "/exception", + } + ) + expect(breadcrumb["data"].keys).not_to include("controller") + end end end