Class: Sentry::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- Sentry::Railtie
- Defined in:
- lib/sentry/rails/railtie.rb
Instance Method Summary collapse
- #activate_tracing ⇒ Object
- #configure_cron_timezone ⇒ Object
- #configure_project_root ⇒ Object
- #configure_trusted_proxies ⇒ Object
- #extend_controller_methods ⇒ Object
- #inject_breadcrumbs_logger ⇒ Object
- #override_streaming_reporter ⇒ Object
- #patch_background_worker ⇒ Object
- #register_error_subscriber(app) ⇒ Object
- #setup_backtrace_cleanup_callback ⇒ Object
Instance Method Details
#activate_tracing ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/sentry/rails/railtie.rb', line 132 def activate_tracing if Sentry.configuration.tracing_enabled? && Sentry.configuration.instrumenter == :sentry 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_cron_timezone ⇒ Object
81 82 83 84 |
# File 'lib/sentry/rails/railtie.rb', line 81 def configure_cron_timezone tz_info = ::ActiveSupport::TimeZone.find_tzinfo(::Rails.application.config.time_zone) Sentry.configuration.cron.default_timezone = tz_info.name end |
#configure_project_root ⇒ Object
73 74 75 |
# File 'lib/sentry/rails/railtie.rb', line 73 def configure_project_root Sentry.configuration.project_root = ::Rails.root.to_s end |
#configure_trusted_proxies ⇒ Object
77 78 79 |
# File 'lib/sentry/rails/railtie.rb', line 77 def configure_trusted_proxies Sentry.configuration.trusted_proxies += Array(::Rails.application.config.action_dispatch.trusted_proxies) end |
#extend_controller_methods ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/sentry/rails/railtie.rb', line 86 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 ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/sentry/rails/railtie.rb', line 102 def if Sentry.configuration..include?(:active_support_logger) require "sentry/rails/breadcrumb/active_support_logger" Sentry::Rails::Breadcrumb::ActiveSupportLogger.inject(Sentry.configuration.rails.active_support_logger_subscription_items) end if Sentry.configuration..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 ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/sentry/rails/railtie.rb', line 124 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 ⇒ Object
98 99 100 |
# File 'lib/sentry/rails/railtie.rb', line 98 def patch_background_worker require "sentry/rails/background_worker" end |
#register_error_subscriber(app) ⇒ Object
141 142 143 144 |
# File 'lib/sentry/rails/railtie.rb', line 141 def register_error_subscriber(app) require "sentry/rails/error_subscriber" app.executor.error_reporter.subscribe(Sentry::Rails::ErrorSubscriber.new) end |
#setup_backtrace_cleanup_callback ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/sentry/rails/railtie.rb', line 116 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 |