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.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/sentry/rails/configuration.rb', line 169

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::ActiveSupportSubscriber,
    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
  @active_job_report_on_retry_error = false
  @structured_logging = StructuredLoggingConfiguration.new
end

Instance Attribute Details

#active_job_report_on_retry_errorObject

Set this option to true if you want Sentry to capture each retry failure



163
164
165
# File 'lib/sentry/rails/configuration.rb', line 163

def active_job_report_on_retry_error
  @active_job_report_on_retry_error
end

#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>>)


160
161
162
# File 'lib/sentry/rails/configuration.rb', line 160

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 “‘



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

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.



141
142
143
# File 'lib/sentry/rails/configuration.rb', line 141

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.



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

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



121
122
123
# File 'lib/sentry/rails/configuration.rb', line 121

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.



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

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.



131
132
133
# File 'lib/sentry/rails/configuration.rb', line 131

def skippable_job_adapters
  @skippable_job_adapters
end

#structured_loggingStructuredLoggingConfiguration (readonly)

Configuration for structured logging feature



167
168
169
# File 'lib/sentry/rails/configuration.rb', line 167

def structured_logging
  @structured_logging
end

#tracing_subscribersObject

Returns the value of attribute tracing_subscribers.



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

def tracing_subscribers
  @tracing_subscribers
end