class Sentry::Railtie

Public Instance Methods

activate_tracing() click to toggle source
# File lib/sentry/rails/railtie.rb, line 97
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
configure_project_root() click to toggle source
# File lib/sentry/rails/railtie.rb, line 43
def configure_project_root
  Sentry.configuration.project_root = ::Rails.root.to_s
end
configure_trusted_proxies() click to toggle source
# File lib/sentry/rails/railtie.rb, line 47
def configure_trusted_proxies
  Sentry.configuration.trusted_proxies += Array(::Rails.application.config.action_dispatch.trusted_proxies)
end
extend_controller_methods() click to toggle source
# File lib/sentry/rails/railtie.rb, line 51
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
inject_breadcrumbs_logger() click to toggle source
# File lib/sentry/rails/railtie.rb, line 67
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
override_streaming_reporter() click to toggle source
# File lib/sentry/rails/railtie.rb, line 89
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
patch_background_worker() click to toggle source
# File lib/sentry/rails/railtie.rb, line 63
def patch_background_worker
  require "sentry/rails/background_worker"
end
setup_backtrace_cleanup_callback() click to toggle source
# File lib/sentry/rails/railtie.rb, line 81
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