Class: Sentry::Configuration
- Inherits:
- 
      Object
      
        - Object
- Sentry::Configuration
 
- Includes:
- ArgumentCheckingHelper, CustomInspection, LoggingHelper
- Defined in:
- lib/sentry/configuration.rb
Constant Summary collapse
- PUMA_IGNORE_DEFAULT =
          These exceptions could enter Puma’s ‘lowlevel_error_handler` callback and the SDK’s Puma integration But they are mostly considered as noise and should be ignored by default Please see github.com/getsentry/sentry-ruby/pull/2026 for more information 
- [ "Puma::MiniSSL::SSLError", "Puma::HttpParserError", "Puma::HttpParserError501" ].freeze 
- IGNORE_DEFAULT =
          Most of these errors generate 4XX responses. In general, Sentry clients only automatically report 5xx responses. 
- [ "Mongoid::Errors::DocumentNotFound", "Rack::QueryParser::InvalidParameterError", "Rack::QueryParser::ParameterTypeError", "Sinatra::NotFound" ].freeze 
- RACK_ENV_WHITELIST_DEFAULT =
- %w[ REMOTE_ADDR SERVER_NAME SERVER_PORT ].freeze 
- TRACE_IGNORE_STATUS_CODES_DEFAULT =
- [(301..303), (305..399), (401..404)] 
- HEROKU_DYNO_METADATA_MESSAGE =
- "You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's "\ "release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`" 
- LOG_PREFIX =
- "** [Sentry] "
- MODULE_SEPARATOR =
- "::"
- SKIP_INSPECTION_ATTRIBUTES =
- [:@linecache, :@stacktrace_builder] 
- INSTRUMENTERS =
- [:sentry, :otel] 
- PROPAGATION_TARGETS_MATCH_ALL =
- /.*/
- DEFAULT_PATCHES =
- i[redis puma http].freeze 
- APP_DIRS_PATTERN =
- /(bin|exe|app|config|lib|test|spec)/
- DEFAULT_PROFILES_SAMPLE_INTERVAL =
          101 Hz in microseconds 
- 1e6 / 101 
Instance Attribute Summary collapse
- 
  
    
      #app_dirs_pattern  ⇒ Regexp? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Directories to be recognized as part of your app. 
- 
  
    
      #auto_session_tracking  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Track sessions in request/response cycles automatically. 
- 
  
    
      #background_worker_max_queue  ⇒ Integer 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The maximum queue size for the background worker. 
- 
  
    
      #background_worker_threads  ⇒ Integer 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    to send events in a non-blocking way, sentry-ruby has its own background worker by default, the worker holds a thread pool that has [the number of processors] threads but you can configure it with this configuration option E.g.: config.background_worker_threads = 5. 
- 
  
    
      #backtrace_cleanup_callback  ⇒ Proc? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    a proc/lambda that takes an array of stack traces it’ll be used to silence (reduce) backtrace of the exception. 
- 
  
    
      #before_breadcrumb  ⇒ Proc 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Optional Proc, called before adding the breadcrumb to the current scope. 
- 
  
    
      #before_send  ⇒ Proc 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Optional Proc, called before sending an error event to the server. 
- 
  
    
      #before_send_check_in  ⇒ Proc 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Optional Proc, called before sending a check-in event to the server. 
- 
  
    
      #before_send_log  ⇒ Proc 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Optional Proc, called before sending an event to the server. 
- 
  
    
      #before_send_transaction  ⇒ Proc 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Optional Proc, called before sending a transaction event to the server. 
- 
  
    
      #breadcrumbs_logger  ⇒ Array<Symbol> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    An array of breadcrumbs loggers to be used. 
- 
  
    
      #context_lines  ⇒ Integer? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Number of lines of code context to capture, or nil for none. 
- 
  
    
      #cron  ⇒ Cron::Configuration 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Cron related configuration. 
- 
  
    
      #debug  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Whether the SDK should run in the debugging mode. 
- 
  
    
      #dsn  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    the dsn value, whether it’s set via ‘config.dsn=` or `ENV`. 
- 
  
    
      #enable_backpressure_handling  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Whether to downsample transactions automatically because of backpressure. 
- 
  
    
      #enable_logs  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Enable Structured Logging. 
- 
  
    
      #enabled_environments  ⇒ Array<String>? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Whitelist of enabled_environments that will send notifications to Sentry. 
- 
  
    
      #enabled_patches  ⇒ Array<Symbol> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Array of patches to apply. 
- 
  
    
      #environment  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    RACK_ENV by default. 
- 
  
    
      #exclude_loggers  ⇒ Array<String> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Logger ‘progname’s to exclude from breadcrumbs. 
- 
  
    
      #excluded_exceptions  ⇒ Array<String> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Array of exception classes that should never be sent. 
- 
  
    
      #include_local_variables  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Whether to capture local variables from the raised exception’s frame. 
- 
  
    
      #inspect_exception_causes_for_exclusion  ⇒ Boolean 
    
    
      (also: #inspect_exception_causes_for_exclusion?)
    
  
  
  
  
    
    
  
  
  
  
  
  
    Boolean to check nested exceptions when deciding if to exclude. 
- 
  
    
      #instrumenter  ⇒ Symbol 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The instrumenter to use, :sentry or :otel. 
- 
  
    
      #linecache  ⇒ LineCache 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    You may provide your own LineCache for matching paths with source files. 
- 
  
    
      #max_breadcrumbs  ⇒ Integer 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Max number of breadcrumbs a breadcrumb buffer can hold. 
- 
  
    
      #max_log_events  ⇒ Integer 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Maximum number of log events to buffer before sending. 
- 
  
    
      #profiler_class  ⇒ Class 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The profiler class. 
- 
  
    
      #profiles_sample_interval  ⇒ Float 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Interval in microseconds at which to take samples. 
- 
  
    
      #profiles_sample_rate  ⇒ Float? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Take a float between 0.0 and 1.0 as the sample rate for capturing profiles. 
- 
  
    
      #project_root  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Project directory root for in_app detection. 
- 
  
    
      #propagate_traces  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Insert sentry-trace to outgoing requests’ headers. 
- 
  
    
      #rack_env_whitelist  ⇒ Array<String> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Array of rack env parameters to be included in the event sent to sentry. 
- 
  
    
      #release  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Release tag to be passed with every event sent to Sentry. 
- 
  
    
      #sample_rate  ⇒ Float 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The sampling factor to apply to events. 
- 
  
    
      #sdk_debug_transport_log_file  ⇒ String? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    File path for DebugTransport to log events to. 
- 
  
    
      #sdk_logger  ⇒ Logger 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Logger used by Sentry. 
- 
  
    
      #send_client_reports  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Send diagnostic client reports about dropped events, true by default tries to attach to an existing envelope max once every 30s. 
- 
  
    
      #send_default_pii  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    When send_default_pii’s value is false (default), sensitive information like - user ip - user cookie - request body - query string will not be sent to Sentry. 
- 
  
    
      #send_modules  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Include module versions in reports - boolean. 
- #server_name ⇒ String
- 
  
    
      #skip_rake_integration  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Allow to skip Sentry emails within rake tasks. 
- 
  
    
      #spotlight  ⇒ Boolean, String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Whether to capture events and traces into Spotlight. 
- 
  
    
      #strip_backtrace_load_path  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Whether to strip the load path while constructing the backtrace frame filename. 
- 
  
    
      #structured_logging  ⇒ StructuredLoggingConfiguration 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Structured logging configuration. 
- 
  
    
      #trace_ignore_status_codes  ⇒ Array<Integer>, Array<Range> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Collection of HTTP status codes or ranges of codes to ignore when tracing incoming requests. 
- 
  
    
      #trace_propagation_targets  ⇒ Array<String, Regexp> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Allowlist of outgoing request targets to which sentry-trace and baggage headers are attached. 
- 
  
    
      #traces_sample_rate  ⇒ Float? 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Take a float between 0.0 and 1.0 as the sample rate for tracing events (transactions). 
- 
  
    
      #traces_sampler  ⇒ Proc 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Take a Proc that controls the sample rate for every tracing event, e.g. 
- 
  
    
      #transport  ⇒ Transport::Configuration 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Transport related configuration. 
- 
  
    
      #trusted_proxies  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    IP ranges for trusted proxies that will be skipped when calculating IP address. 
Class Method Summary collapse
- 
  
    
      .add_post_initialization_callback(&block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    allow extensions to add their hooks to the Configuration class. 
- .after(event, &block) ⇒ Object
- .before(event, &block) ⇒ Object
- 
  
    
      .post_initialization_callbacks  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Post initialization callbacks are called at the end of initialization process allowing extending the configuration of sentry-ruby by multiple extensions. 
- .validate(attribute, optional: false, type: nil) ⇒ Object
- .validations ⇒ Object
Instance Method Summary collapse
- #csp_report_uri ⇒ String?
- #detect_release ⇒ Object private
- #enabled_in_current_env? ⇒ Boolean
- #error_messages ⇒ Object private
- #exception_class_allowed?(exc) ⇒ Boolean
- 
  
    
      #initialize {|_self| ... } ⇒ Configuration 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Configuration. 
- #profiling_enabled? ⇒ Boolean
- #sample_allowed? ⇒ Boolean
- #sending_allowed? ⇒ Boolean
- #sending_to_dsn_allowed? ⇒ Boolean
- #session_tracking? ⇒ Boolean
- #stacktrace_builder ⇒ Object private
- #tracing_enabled? ⇒ Boolean
- #valid_sample_rate?(sample_rate) ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
| 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | # File 'lib/sentry/configuration.rb', line 456 def initialize run_callbacks(:before, :initialize) self.app_dirs_pattern = APP_DIRS_PATTERN self.debug = Sentry::Utils::EnvHelper.env_to_bool(ENV["SENTRY_DEBUG"]) self.background_worker_threads = (processor_count / 2.0).ceil self.background_worker_max_queue = BackgroundWorker::DEFAULT_MAX_QUEUE self.backtrace_cleanup_callback = nil self.strip_backtrace_load_path = true self. = BreadcrumbBuffer::DEFAULT_SIZE self. = [] self.context_lines = 3 self.include_local_variables = false self.environment = environment_from_env self.enabled_environments = nil self.exclude_loggers = [] self.excluded_exceptions = IGNORE_DEFAULT + PUMA_IGNORE_DEFAULT self.inspect_exception_causes_for_exclusion = true self.linecache = ::Sentry::LineCache.new self.sdk_logger = ::Sentry::Logger.new(STDOUT) self.project_root = Dir.pwd self.propagate_traces = true self.sample_rate = 1.0 self.send_modules = true self.send_default_pii = false self.skip_rake_integration = false self.send_client_reports = true self.auto_session_tracking = true self.enable_backpressure_handling = false self.trusted_proxies = [] self.dsn = ENV["SENTRY_DSN"] spotlight_env = ENV["SENTRY_SPOTLIGHT"] spotlight_bool = Sentry::Utils::EnvHelper.env_to_bool(spotlight_env, strict: true) self.spotlight = spotlight_bool.nil? ? (spotlight_env || false) : spotlight_bool self.server_name = server_name_from_env self.instrumenter = :sentry self.trace_propagation_targets = [PROPAGATION_TARGETS_MATCH_ALL] self.trace_ignore_status_codes = TRACE_IGNORE_STATUS_CODES_DEFAULT self.enabled_patches = DEFAULT_PATCHES.dup self.before_send = nil self.before_send_transaction = nil self.before_send_check_in = nil self.before_send_log = nil self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT self.traces_sampler = nil self.enable_logs = false self.profiler_class = Sentry::Profiler self.profiles_sample_interval = DEFAULT_PROFILES_SAMPLE_INTERVAL @transport = Transport::Configuration.new @cron = Cron::Configuration.new @structured_logging = StructuredLoggingConfiguration.new @gem_specs = Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map) self.max_log_events = LogEventBuffer::DEFAULT_MAX_EVENTS run_callbacks(:after, :initialize) yield(self) if block_given? run_callbacks(:after, :configured) end | 
Instance Attribute Details
#app_dirs_pattern ⇒ Regexp?
Directories to be recognized as part of your app. e.g. if you have an ‘engines` dir at the root of your project, you may want to set this to something like /(app|config|engines|lib)/
The default is value is /(bin|exe|app|config|lib|test|spec)/
| 31 32 33 | # File 'lib/sentry/configuration.rb', line 31 def app_dirs_pattern @app_dirs_pattern end | 
#auto_session_tracking ⇒ Boolean
Track sessions in request/response cycles automatically
| 283 284 285 | # File 'lib/sentry/configuration.rb', line 283 def auto_session_tracking @auto_session_tracking end | 
#background_worker_max_queue ⇒ Integer
The maximum queue size for the background worker. Jobs will be rejected above this limit.
Default is BackgroundWorker::DEFAULT_MAX_QUEUE.
| 48 49 50 | # File 'lib/sentry/configuration.rb', line 48 def background_worker_max_queue @background_worker_max_queue end | 
#background_worker_threads ⇒ Integer
to send events in a non-blocking way, sentry-ruby has its own background worker by default, the worker holds a thread pool that has [the number of processors] threads but you can configure it with this configuration option E.g.: config.background_worker_threads = 5
if you want to send events synchronously, set the value to 0 E.g.: config.background_worker_threads = 0
| 41 42 43 | # File 'lib/sentry/configuration.rb', line 41 def background_worker_threads @background_worker_threads end | 
#backtrace_cleanup_callback ⇒ Proc?
a proc/lambda that takes an array of stack traces it’ll be used to silence (reduce) backtrace of the exception
| 59 60 61 | # File 'lib/sentry/configuration.rb', line 59 def backtrace_cleanup_callback @backtrace_cleanup_callback end | 
#before_breadcrumb ⇒ Proc
Optional Proc, called before adding the breadcrumb to the current scope
| 68 69 70 | # File 'lib/sentry/configuration.rb', line 68 def end | 
#before_send ⇒ Proc
Optional Proc, called before sending an error event to the server
| 81 82 83 | # File 'lib/sentry/configuration.rb', line 81 def before_send @before_send end | 
#before_send_check_in ⇒ Proc
Optional Proc, called before sending a check-in event to the server
| 106 107 108 | # File 'lib/sentry/configuration.rb', line 106 def before_send_check_in @before_send_check_in end | 
#before_send_log ⇒ Proc
Optional Proc, called before sending an event to the server
| 115 116 117 | # File 'lib/sentry/configuration.rb', line 115 def before_send_log @before_send_log end | 
#before_send_transaction ⇒ Proc
Optional Proc, called before sending a transaction event to the server
| 94 95 96 | # File 'lib/sentry/configuration.rb', line 94 def before_send_transaction @before_send_transaction end | 
#breadcrumbs_logger ⇒ Array<Symbol>
An array of breadcrumbs loggers to be used. Available options are:
- 
:sentry_logger 
- 
:http_logger 
- 
:redis_logger 
And if you also use sentry-rails:
- 
:active_support_logger 
| 126 127 128 | # File 'lib/sentry/configuration.rb', line 126 def end | 
#context_lines ⇒ Integer?
Number of lines of code context to capture, or nil for none
| 134 135 136 | # File 'lib/sentry/configuration.rb', line 134 def context_lines @context_lines end | 
#cron ⇒ Cron::Configuration (readonly)
Cron related configuration.
| 252 253 254 | # File 'lib/sentry/configuration.rb', line 252 def cron @cron end | 
#debug ⇒ Boolean
Whether the SDK should run in the debugging mode. Default is false. If set to true, SDK errors will be logged with backtrace
| 143 144 145 | # File 'lib/sentry/configuration.rb', line 143 def debug @debug end | 
#dsn ⇒ String
the dsn value, whether it’s set via ‘config.dsn=` or `ENV`
| 147 148 149 | # File 'lib/sentry/configuration.rb', line 147 def dsn @dsn end | 
#enable_backpressure_handling ⇒ Boolean
Whether to downsample transactions automatically because of backpressure. Starts a new monitor thread to check health of the SDK every 10 seconds. Default is false
| 289 290 291 | # File 'lib/sentry/configuration.rb', line 289 def enable_backpressure_handling @enable_backpressure_handling end | 
#enable_logs ⇒ Boolean
Enable Structured Logging
| 270 271 272 | # File 'lib/sentry/configuration.rb', line 270 def enable_logs @enable_logs end | 
#enabled_environments ⇒ Array<String>?
Whitelist of enabled_environments that will send notifications to Sentry. Array of Strings.
| 151 152 153 | # File 'lib/sentry/configuration.rb', line 151 def enabled_environments @enabled_environments end | 
#enabled_patches ⇒ Array<Symbol>
Array of patches to apply. Default is DEFAULT_PATCHES
| 334 335 336 | # File 'lib/sentry/configuration.rb', line 334 def enabled_patches @enabled_patches end | 
#environment ⇒ String
RACK_ENV by default.
| 138 139 140 | # File 'lib/sentry/configuration.rb', line 138 def environment @environment end | 
#exclude_loggers ⇒ Array<String>
Logger ‘progname’s to exclude from breadcrumbs
| 155 156 157 | # File 'lib/sentry/configuration.rb', line 155 def exclude_loggers @exclude_loggers end | 
#excluded_exceptions ⇒ Array<String>
Array of exception classes that should never be sent. See IGNORE_DEFAULT. You should probably append to this rather than overwrite it.
| 160 161 162 | # File 'lib/sentry/configuration.rb', line 160 def excluded_exceptions @excluded_exceptions end | 
#include_local_variables ⇒ Boolean
Whether to capture local variables from the raised exception’s frame. Default is false.
| 169 170 171 | # File 'lib/sentry/configuration.rb', line 169 def include_local_variables @include_local_variables end | 
#inspect_exception_causes_for_exclusion ⇒ Boolean Also known as: inspect_exception_causes_for_exclusion?
Boolean to check nested exceptions when deciding if to exclude. Defaults to true
| 164 165 166 | # File 'lib/sentry/configuration.rb', line 164 def inspect_exception_causes_for_exclusion @inspect_exception_causes_for_exclusion end | 
#instrumenter ⇒ Symbol
The instrumenter to use, :sentry or :otel
| 310 311 312 | # File 'lib/sentry/configuration.rb', line 310 def instrumenter @instrumenter end | 
#linecache ⇒ LineCache
You may provide your own LineCache for matching paths with source files. This may be useful if you need to get source code from places other than the disk.
| 183 184 185 | # File 'lib/sentry/configuration.rb', line 183 def linecache @linecache end | 
#max_breadcrumbs ⇒ Integer
Max number of breadcrumbs a breadcrumb buffer can hold
| 130 131 132 | # File 'lib/sentry/configuration.rb', line 130 def end | 
#max_log_events ⇒ Integer
Maximum number of log events to buffer before sending
| 338 339 340 | # File 'lib/sentry/configuration.rb', line 338 def max_log_events @max_log_events end | 
#profiler_class ⇒ Class
The profiler class
| 314 315 316 | # File 'lib/sentry/configuration.rb', line 314 def profiler_class @profiler_class end | 
#profiles_sample_interval ⇒ Float
Interval in microseconds at which to take samples. The default is 1e6 / 101, or 101Hz. Note that the 101 is intentional to avoid lockstep sampling.
| 329 330 331 | # File 'lib/sentry/configuration.rb', line 329 def profiles_sample_interval @profiles_sample_interval end | 
#profiles_sample_rate ⇒ Float?
Take a float between 0.0 and 1.0 as the sample rate for capturing profiles. Note that this rate is relative to traces_sample_rate / traces_sampler, i.e. the profile is sampled by this rate after the transaction is sampled.
| 320 321 322 | # File 'lib/sentry/configuration.rb', line 320 def profiles_sample_rate @profiles_sample_rate end | 
#project_root ⇒ String
Project directory root for in_app detection. Could be Rails root, etc. Set automatically for Rails.
| 198 199 200 | # File 'lib/sentry/configuration.rb', line 198 def project_root @project_root end | 
#propagate_traces ⇒ Boolean
Insert sentry-trace to outgoing requests’ headers
| 207 208 209 | # File 'lib/sentry/configuration.rb', line 207 def propagate_traces @propagate_traces end | 
#rack_env_whitelist ⇒ Array<String>
Array of rack env parameters to be included in the event sent to sentry.
| 211 212 213 | # File 'lib/sentry/configuration.rb', line 211 def rack_env_whitelist @rack_env_whitelist end | 
#release ⇒ String
Release tag to be passed with every event sent to Sentry. We automatically try to set this to a git SHA or Capistrano release.
| 216 217 218 | # File 'lib/sentry/configuration.rb', line 216 def release @release end | 
#sample_rate ⇒ Float
The sampling factor to apply to events. A value of 0.0 will not send any events, and a value of 1.0 will send 100% of events.
| 221 222 223 | # File 'lib/sentry/configuration.rb', line 221 def sample_rate @sample_rate end | 
#sdk_debug_transport_log_file ⇒ String?
File path for DebugTransport to log events to. If not set, defaults to a temporary file. This is useful for debugging and testing purposes.
| 193 194 195 | # File 'lib/sentry/configuration.rb', line 193 def sdk_debug_transport_log_file @sdk_debug_transport_log_file end | 
#sdk_logger ⇒ Logger
Logger used by Sentry. In Rails, this is the Rails logger, otherwise Sentry provides its own Sentry::Logger.
| 188 189 190 | # File 'lib/sentry/configuration.rb', line 188 def sdk_logger @sdk_logger end | 
#send_client_reports ⇒ Boolean
Send diagnostic client reports about dropped events, true by default tries to attach to an existing envelope max once every 30s
| 279 280 281 | # File 'lib/sentry/configuration.rb', line 279 def send_client_reports @send_client_reports end | 
#send_default_pii ⇒ Boolean
When send_default_pii’s value is false (default), sensitive information like
- 
user ip 
- 
user cookie 
- 
request body 
- 
query string 
will not be sent to Sentry.
| 234 235 236 | # File 'lib/sentry/configuration.rb', line 234 def send_default_pii @send_default_pii end | 
#send_modules ⇒ Boolean
Include module versions in reports - boolean.
| 225 226 227 | # File 'lib/sentry/configuration.rb', line 225 def send_modules @send_modules end | 
#server_name ⇒ String
| 244 245 246 | # File 'lib/sentry/configuration.rb', line 244 def server_name @server_name end | 
#skip_rake_integration ⇒ Boolean
Allow to skip Sentry emails within rake tasks
| 238 239 240 | # File 'lib/sentry/configuration.rb', line 238 def skip_rake_integration @skip_rake_integration end | 
#spotlight ⇒ Boolean, String
Whether to capture events and traces into Spotlight. Default is false. If you set this to true, Sentry will send events and traces to the local Sidecar proxy at localhost:8969/stream. If you want to use a different Sidecar proxy address, set this to String with the proxy URL.
| 177 178 179 | # File 'lib/sentry/configuration.rb', line 177 def spotlight @spotlight end | 
#strip_backtrace_load_path ⇒ Boolean
Whether to strip the load path while constructing the backtrace frame filename. Defaults to true.
| 203 204 205 | # File 'lib/sentry/configuration.rb', line 203 def strip_backtrace_load_path @strip_backtrace_load_path end | 
#structured_logging ⇒ StructuredLoggingConfiguration (readonly)
Structured logging configuration.
| 274 275 276 | # File 'lib/sentry/configuration.rb', line 274 def structured_logging @structured_logging end | 
#trace_ignore_status_codes ⇒ Array<Integer>, Array<Range>
Collection of HTTP status codes or ranges of codes to ignore when tracing incoming requests. If a transaction’s http.response.status_code matches one of these values, the transaction will be dropped and marked as not sampled. Defaults to TRACE_IGNORE_STATUS_CODES_DEFAULT.
| 306 307 308 | # File 'lib/sentry/configuration.rb', line 306 def trace_ignore_status_codes @trace_ignore_status_codes end | 
#trace_propagation_targets ⇒ Array<String, Regexp>
Allowlist of outgoing request targets to which sentry-trace and baggage headers are attached. Default is all (/.*/)
| 294 295 296 | # File 'lib/sentry/configuration.rb', line 294 def trace_propagation_targets @trace_propagation_targets end | 
#traces_sample_rate ⇒ Float?
Take a float between 0.0 and 1.0 as the sample rate for tracing events (transactions).
| 256 257 258 | # File 'lib/sentry/configuration.rb', line 256 def traces_sample_rate @traces_sample_rate end | 
#traces_sampler ⇒ Proc
Take a Proc that controls the sample rate for every tracing event, e.g.
| 266 267 268 | # File 'lib/sentry/configuration.rb', line 266 def traces_sampler @traces_sampler end | 
#transport ⇒ Transport::Configuration (readonly)
Transport related configuration.
| 248 249 250 | # File 'lib/sentry/configuration.rb', line 248 def transport @transport end | 
#trusted_proxies ⇒ Object
IP ranges for trusted proxies that will be skipped when calculating IP address.
| 241 242 243 | # File 'lib/sentry/configuration.rb', line 241 def trusted_proxies @trusted_proxies end | 
Class Method Details
.add_post_initialization_callback(&block) ⇒ Object
allow extensions to add their hooks to the Configuration class
| 396 397 398 | # File 'lib/sentry/configuration.rb', line 396 def add_post_initialization_callback(&block) callbacks[:initialize][:after] << block end | 
.after(event, &block) ⇒ Object
| 404 405 406 | # File 'lib/sentry/configuration.rb', line 404 def after(event, &block) callbacks[event.to_sym][:after] << block end | 
.before(event, &block) ⇒ Object
| 400 401 402 | # File 'lib/sentry/configuration.rb', line 400 def before(event, &block) callbacks[event.to_sym][:before] << block end | 
.post_initialization_callbacks ⇒ Object
Post initialization callbacks are called at the end of initialization process allowing extending the configuration of sentry-ruby by multiple extensions
| 391 392 393 | # File 'lib/sentry/configuration.rb', line 391 def post_initialization_callbacks @post_initialization_callbacks ||= [] end | 
.validate(attribute, optional: false, type: nil) ⇒ Object
| 420 421 422 423 424 425 426 | # File 'lib/sentry/configuration.rb', line 420 def validate(attribute, optional: false, type: nil) validations[attribute] = { optional: optional, type: type, proc: build_validation_proc(optional, type) } end | 
.validations ⇒ Object
| 416 417 418 | # File 'lib/sentry/configuration.rb', line 416 def validations @validations ||= {} end | 
Instance Method Details
#csp_report_uri ⇒ String?
| 680 681 682 683 684 685 686 687 | # File 'lib/sentry/configuration.rb', line 680 def csp_report_uri if dsn && dsn.valid? uri = dsn.csp_report_uri uri += "&sentry_release=#{CGI.escape(release)}" if release && !release.empty? uri += "&sentry_environment=#{CGI.escape(environment)}" if environment && !environment.empty? uri end end | 
#detect_release ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 702 703 704 705 706 707 708 709 710 711 712 | # File 'lib/sentry/configuration.rb', line 702 def detect_release return unless sending_allowed? @release ||= ReleaseDetector.detect_release(project_root: project_root, running_on_heroku: running_on_heroku?) if running_on_heroku? && release.nil? log_warn(HEROKU_DYNO_METADATA_MESSAGE) end rescue => e log_error("Error detecting release", e, debug: debug) end | 
#enabled_in_current_env? ⇒ Boolean
| 658 659 660 | # File 'lib/sentry/configuration.rb', line 658 def enabled_in_current_env? enabled_environments.nil? || enabled_environments.include?(environment) end | 
#error_messages ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 715 716 717 718 | # File 'lib/sentry/configuration.rb', line 715 def @errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first @errors.join(", ") end | 
#exception_class_allowed?(exc) ⇒ Boolean
| 645 646 647 648 649 650 651 652 653 654 655 656 | # File 'lib/sentry/configuration.rb', line 645 def exception_class_allowed?(exc) if exc.is_a?(Sentry::Error) # Try to prevent error reporting loops log_debug("Refusing to capture Sentry error: #{exc.inspect}") false elsif excluded_exception?(exc) log_debug("User excluded error: #{exc.inspect}") false else true end end | 
#profiling_enabled? ⇒ Boolean
| 673 674 675 676 677 | # File 'lib/sentry/configuration.rb', line 673 def profiling_enabled? valid_sampler = !!(valid_sample_rate?(@profiles_sample_rate)) tracing_enabled? && valid_sampler && sending_allowed? end | 
#sample_allowed? ⇒ Boolean
| 635 636 637 638 639 | # File 'lib/sentry/configuration.rb', line 635 def sample_allowed? return true if sample_rate == 1.0 Random.rand < sample_rate end | 
#sending_allowed? ⇒ Boolean
| 625 626 627 | # File 'lib/sentry/configuration.rb', line 625 def sending_allowed? spotlight || sending_to_dsn_allowed? end | 
#sending_to_dsn_allowed? ⇒ Boolean
| 629 630 631 632 633 | # File 'lib/sentry/configuration.rb', line 629 def sending_to_dsn_allowed? @errors = [] valid? && capture_in_environment? end | 
#session_tracking? ⇒ Boolean
| 641 642 643 | # File 'lib/sentry/configuration.rb', line 641 def session_tracking? auto_session_tracking && enabled_in_current_env? end | 
#stacktrace_builder ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 690 691 692 693 694 695 696 697 698 699 | # File 'lib/sentry/configuration.rb', line 690 def stacktrace_builder @stacktrace_builder ||= StacktraceBuilder.new( project_root: @project_root.to_s, app_dirs_pattern: @app_dirs_pattern, linecache: @linecache, context_lines: @context_lines, backtrace_cleanup_callback: @backtrace_cleanup_callback, strip_backtrace_load_path: @strip_backtrace_load_path ) end | 
#tracing_enabled? ⇒ Boolean
| 667 668 669 670 671 | # File 'lib/sentry/configuration.rb', line 667 def tracing_enabled? valid_sampler = !!((valid_sample_rate?(@traces_sample_rate)) || @traces_sampler) valid_sampler && sending_allowed? end | 
#valid_sample_rate?(sample_rate) ⇒ Boolean
| 662 663 664 665 | # File 'lib/sentry/configuration.rb', line 662 def valid_sample_rate?(sample_rate) return false unless sample_rate.is_a?(Numeric) sample_rate >= 0.0 && sample_rate <= 1.0 end | 
#validate ⇒ Object
| 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | # File 'lib/sentry/configuration.rb', line 523 def validate if profiler_class == Sentry::Profiler && profiles_sample_rate && !Sentry.dependency_installed?(:StackProf) log_warn("Please add the 'stackprof' gem to your Gemfile to use the StackProf profiler with Sentry.") end if profiler_class == Sentry::Vernier::Profiler && profiles_sample_rate && !Sentry.dependency_installed?(:Vernier) log_warn("Please add the 'vernier' gem to your Gemfile to use the Vernier profiler with Sentry.") end self.class.validations.each do |attribute, validation| value = public_send(attribute) next if (result = validation[:proc].call(value)) === true raise ArgumentError, result[:error] end end |