Class: Sentry::Rails::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry/rails/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/sentry/rails/configuration.rb', line 158

def initialize
  @register_error_subscriber = false
  @report_rescued_exceptions = true
  @skippable_job_adapters = []
  @assets_regexp = if defined?(::Sprockets::Rails)
    %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
  end
  @tracing_subscribers = Set.new([
    Sentry::Rails::Tracing::ActionViewSubscriber,
    Sentry::Rails::Tracing::ActiveRecordSubscriber,
    Sentry::Rails::Tracing::ActiveStorageSubscriber
  ])
  @enable_db_query_source = true
  @db_query_source_threshold_ms = 100
  @active_support_logger_subscription_items = Sentry::Rails::ACTIVE_SUPPORT_LOGGER_SUBSCRIPTION_ITEMS_DEFAULT.dup
end

Instance Attribute Details

#active_support_logger_subscription_itemsHash<String, Array<Symbol>>

Hash of subscription items that will be shown in breadcrumbs active support logger.

Returns:

  • (Hash<String, Array<Symbol>>)


156
157
158
# File 'lib/sentry/rails/configuration.rb', line 156

def active_support_logger_subscription_items
  @active_support_logger_subscription_items
end

#assets_regexpObject

sentry-rails by default skips asset request’ transactions by checking if the path matches

“‘rb %r(A/0,2#Rails.application.config.assets.prefix) “`

If you want to use a different pattern, you can configure the ‘assets_regexp` option like:

“‘rb Sentry.init do |config|

config.rails.assets_regexp = /my_regexp/

end “‘



152
153
154
# File 'lib/sentry/rails/configuration.rb', line 152

def assets_regexp
  @assets_regexp
end

#db_query_source_threshold_msObject

The threshold in milliseconds for the ActiveRecordSubscriber to capture the source location of the query in the span data. Default is 100ms.



137
138
139
# File 'lib/sentry/rails/configuration.rb', line 137

def db_query_source_threshold_ms
  @db_query_source_threshold_ms
end

#enable_db_query_sourceObject

When the ActiveRecordSubscriber is enabled, capture the source location of the query in the span data. This is enabled by default, but can be disabled by setting this to false.



133
134
135
# File 'lib/sentry/rails/configuration.rb', line 133

def enable_db_query_source
  @enable_db_query_source
end

#register_error_subscriberObject

Rails 7.0 introduced a new error reporter feature, which the SDK once opted-in by default. But after receiving multiple issue reports, the integration seemed to cause serious troubles to some users. So the integration is now controlled by this configuration, which is disabled (false) by default. More information can be found from: github.com/rails/rails/pull/43625#issuecomment-1072514175



117
118
119
# File 'lib/sentry/rails/configuration.rb', line 117

def register_error_subscriber
  @register_error_subscriber
end

#report_rescued_exceptionsObject

Rails catches exceptions in the ActionDispatch::ShowExceptions or ActionDispatch::DebugExceptions middlewares, depending on the environment. When ‘report_rescued_exceptions` is true (it is by default), Sentry will report exceptions even when they are rescued by these middlewares.



123
124
125
# File 'lib/sentry/rails/configuration.rb', line 123

def report_rescued_exceptions
  @report_rescued_exceptions
end

#skippable_job_adaptersObject

Some adapters, like sidekiq, already have their own sentry integration. In those cases, we should skip ActiveJob’s reporting to avoid duplicated reports.



127
128
129
# File 'lib/sentry/rails/configuration.rb', line 127

def skippable_job_adapters
  @skippable_job_adapters
end

#tracing_subscribersObject

Returns the value of attribute tracing_subscribers.



129
130
131
# File 'lib/sentry/rails/configuration.rb', line 129

def tracing_subscribers
  @tracing_subscribers
end