class Sentry::Railtie

def activate_tracing

def activate_tracing
  if Sentry.configuration.tracing_enabled?
    subscribers = Sentry.configuration.rails.tracing_subscribers
    Sentry::Rails::Tracing.register_subscribers(subscribers)
    Sentry::Rails::Tracing.subscribe_tracing_events
    Sentry::Rails::Tracing.patch_active_support_notifications
  end
end

def configure_project_root

def configure_project_root
  Sentry.configuration.project_root = ::Rails.root.to_s
end

def configure_trusted_proxies

def configure_trusted_proxies
  Sentry.configuration.trusted_proxies += Array(::Rails.application.config.action_dispatch.trusted_proxies)
end

def extend_controller_methods

def extend_controller_methods
  require "sentry/rails/controller_methods"
  require "sentry/rails/controller_transaction"
  require "sentry/rails/overrides/streaming_reporter"
  ActiveSupport.on_load :action_controller do
    include Sentry::Rails::ControllerMethods
    include Sentry::Rails::ControllerTransaction
    ActionController::Live.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
  end
end

def inject_breadcrumbs_logger

def inject_breadcrumbs_logger
  if Sentry.configuration.breadcrumbs_logger.include?(:active_support_logger)
    require 'sentry/rails/breadcrumb/active_support_logger'
    Sentry::Rails::Breadcrumb::ActiveSupportLogger.inject
  end
  if Sentry.configuration.breadcrumbs_logger.include?(:monotonic_active_support_logger)
    return warn "Usage of `monotonic_active_support_logger` require a version of Rails >= 6.1, please upgrade your Rails version or use another logger" if ::Rails.version.to_f < 6.1
    require 'sentry/rails/breadcrumb/monotonic_active_support_logger'
    Sentry::Rails::Breadcrumb::MonotonicActiveSupportLogger.inject
  end
end

def override_streaming_reporter

def override_streaming_reporter
  require "sentry/rails/overrides/streaming_reporter"
  ActiveSupport.on_load :action_view do
    ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
  end
end

def patch_background_worker

def patch_background_worker
  require "sentry/rails/background_worker"
end

def register_error_subscriber(app)

def register_error_subscriber(app)
  require "sentry/rails/error_subscriber"
  app.executor.error_reporter.subscribe(Sentry::Rails::ErrorSubscriber.new)
end

def setup_backtrace_cleanup_callback

def setup_backtrace_cleanup_callback
  backtrace_cleaner = Sentry::Rails::BacktraceCleaner.new
  Sentry.configuration.backtrace_cleanup_callback ||= lambda do |backtrace|
    backtrace_cleaner.clean(backtrace)
  end
end