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
127 128 129 130 131 132 133 134 |
# File 'lib/sentry/rails/railtie.rb', line 127 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
76 77 78 79 |
# File 'lib/sentry/rails/railtie.rb', line 76 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
68 69 70 |
# File 'lib/sentry/rails/railtie.rb', line 68 def configure_project_root Sentry.configuration.project_root = ::Rails.root.to_s end |
#configure_trusted_proxies ⇒ Object
72 73 74 |
# File 'lib/sentry/rails/railtie.rb', line 72 def configure_trusted_proxies Sentry.configuration.trusted_proxies += Array(::Rails.application.config.action_dispatch.trusted_proxies) end |
#extend_controller_methods ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/sentry/rails/railtie.rb', line 81 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
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sentry/rails/railtie.rb', line 97 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
119 120 121 122 123 124 125 |
# File 'lib/sentry/rails/railtie.rb', line 119 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
93 94 95 |
# File 'lib/sentry/rails/railtie.rb', line 93 def patch_background_worker require "sentry/rails/background_worker" end |
#register_error_subscriber(app) ⇒ Object
136 137 138 139 |
# File 'lib/sentry/rails/railtie.rb', line 136 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
111 112 113 114 115 116 117 |
# File 'lib/sentry/rails/railtie.rb', line 111 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 |