Class: Sentry::Configuration
- Inherits:
-
Object
- Object
- Sentry::Configuration
- Includes:
- ArgumentCheckingHelper, CustomInspection, LoggingHelper
- Defined in:
- lib/sentry/configuration.rb
Constant Summary collapse
- ISOLATION_LEVELS =
Isolation levels the SDK understands for hub storage.
%i[thread fiber].freeze
- PUMA_IGNORE_DEFAULT =
These exceptions could enter Puma's
lowlevel_error_handlercallback and the SDK's Puma integration But they are mostly considered as noise and should be ignored by default Please see https://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_metric ⇒ Proc?
Optional Proc, called before sending a metric.
-
#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.
-
#capture_queue_time ⇒ Boolean
Capture queue time from X-Request-Start header set by reverse proxies.
-
#context_lines ⇒ Integer?
deprecated
Deprecated.
Use #data_collection and
frame_context_linesinstead. -
#cron ⇒ Cron::Configuration
readonly
Cron related configuration.
-
#data_collection ⇒ DataCollection
Controls which categories of data may be collected.
-
#debug ⇒ Boolean
Whether the SDK should run in the debugging mode.
-
#dsn ⇒ String
the dsn value, whether it's set via
config.dsn=orENV["SENTRY_DSN"]. -
#enable_backpressure_handling ⇒ Boolean
Whether to downsample transactions automatically because of backpressure.
-
#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.
-
#hub_isolation_level ⇒ Symbol
Which execution primitive owns the SDK's current hub.
-
#include_local_variables ⇒ Boolean
deprecated
Deprecated.
Use #data_collection and
stack_frame_variablesinstead. -
#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.
-
#max_metric_events ⇒ Integer
Maximum number of metric events to buffer before sending.
-
#org_id ⇒ String?
An optional organization ID.
-
#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>
deprecated
Deprecated.
Use
data_collection.http_headers.requestto control request data collection instead. -
#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
deprecated
Deprecated.
Use #data_collection instead.
-
#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.
-
#std_lib_logger_filter ⇒ Proc?
Optional Proc, called to filter log messages before sending to Sentry.
-
#strict_trace_continuation ⇒ Boolean
If set to true, the SDK will only continue a trace if the org_id of the incoming trace found in the baggage header matches the org_id of the current Sentry client and only if BOTH are present.
-
#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
-
#effective_org_id ⇒ String?
Returns the effective org ID, preferring the explicit config option over the DSN-parsed value.
- #enabled_in_current_env? ⇒ Boolean
- #error_messages ⇒ Object private
- #exception_class_allowed?(exc) ⇒ Boolean
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #log_deprecations ⇒ Object private
- #profiling_enabled? ⇒ Boolean
- #run_after_close_callbacks ⇒ Object private
- #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.
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
# File 'lib/sentry/configuration.rb', line 534 def initialize run_callbacks(:before, :initialize) self.data_collection = DataCollection.new 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"] self.capture_queue_time = true self.org_id = nil self.strict_trace_continuation = false self.hub_isolation_level = :thread 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.before_send_metric = nil self.std_lib_logger_filter = nil self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT self.traces_sampler = nil 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 self.max_metric_events = MetricEventBuffer::DEFAULT_MAX_METRICS run_callbacks(:after, :initialize) yield(self) if block_given? log_deprecations 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)/
34 35 36 |
# File 'lib/sentry/configuration.rb', line 34 def app_dirs_pattern @app_dirs_pattern end |
#auto_session_tracking ⇒ Boolean
Track sessions in request/response cycles automatically
302 303 304 |
# File 'lib/sentry/configuration.rb', line 302 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.
51 52 53 |
# File 'lib/sentry/configuration.rb', line 51 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
44 45 46 |
# File 'lib/sentry/configuration.rb', line 44 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
62 63 64 |
# File 'lib/sentry/configuration.rb', line 62 def backtrace_cleanup_callback @backtrace_cleanup_callback end |
#before_breadcrumb ⇒ Proc
Optional Proc, called before adding the breadcrumb to the current scope
71 72 73 |
# File 'lib/sentry/configuration.rb', line 71 def @before_breadcrumb end |
#before_send ⇒ Proc
Optional Proc, called before sending an error event to the server
84 85 86 |
# File 'lib/sentry/configuration.rb', line 84 def before_send @before_send end |
#before_send_check_in ⇒ Proc
Optional Proc, called before sending a check-in event to the server
109 110 111 |
# File 'lib/sentry/configuration.rb', line 109 def before_send_check_in @before_send_check_in end |
#before_send_log ⇒ Proc
Optional Proc, called before sending an event to the server
118 119 120 |
# File 'lib/sentry/configuration.rb', line 118 def before_send_log @before_send_log end |
#before_send_metric ⇒ Proc?
Optional Proc, called before sending a metric
370 371 372 |
# File 'lib/sentry/configuration.rb', line 370 def before_send_metric @before_send_metric end |
#before_send_transaction ⇒ Proc
Optional Proc, called before sending a transaction event to the server
97 98 99 |
# File 'lib/sentry/configuration.rb', line 97 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
129 130 131 |
# File 'lib/sentry/configuration.rb', line 129 def @breadcrumbs_logger end |
#capture_queue_time ⇒ Boolean
Capture queue time from X-Request-Start header set by reverse proxies. Works with any Rack app behind Nginx, HAProxy, Heroku router, etc. Defaults to true.
257 258 259 |
# File 'lib/sentry/configuration.rb', line 257 def capture_queue_time @capture_queue_time end |
#context_lines ⇒ Integer?
Use #data_collection and frame_context_lines instead.
Number of lines of code context to capture, or nil for none
138 139 140 |
# File 'lib/sentry/configuration.rb', line 138 def context_lines @context_lines end |
#cron ⇒ Cron::Configuration (readonly)
Cron related configuration.
275 276 277 |
# File 'lib/sentry/configuration.rb', line 275 def cron @cron end |
#data_collection ⇒ DataCollection
Controls which categories of data may be collected. Replacement for send_default_pii.
251 252 253 |
# File 'lib/sentry/configuration.rb', line 251 def data_collection @data_collection 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
147 148 149 |
# File 'lib/sentry/configuration.rb', line 147 def debug @debug end |
#dsn ⇒ String
the dsn value, whether it's set via config.dsn= or ENV["SENTRY_DSN"]
151 152 153 |
# File 'lib/sentry/configuration.rb', line 151 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
308 309 310 |
# File 'lib/sentry/configuration.rb', line 308 def enable_backpressure_handling @enable_backpressure_handling end |
#enabled_environments ⇒ Array<String>?
Whitelist of enabled_environments that will send notifications to Sentry. Array of Strings.
155 156 157 |
# File 'lib/sentry/configuration.rb', line 155 def enabled_environments @enabled_environments end |
#enabled_patches ⇒ Array<Symbol>
Array of patches to apply. Default is DEFAULT_PATCHES
353 354 355 |
# File 'lib/sentry/configuration.rb', line 353 def enabled_patches @enabled_patches end |
#environment ⇒ String
RACK_ENV by default.
142 143 144 |
# File 'lib/sentry/configuration.rb', line 142 def environment @environment end |
#exclude_loggers ⇒ Array<String>
Logger 'progname's to exclude from breadcrumbs
159 160 161 |
# File 'lib/sentry/configuration.rb', line 159 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.
164 165 166 |
# File 'lib/sentry/configuration.rb', line 164 def excluded_exceptions @excluded_exceptions end |
#hub_isolation_level ⇒ Symbol
Which execution primitive owns the SDK's current hub.
[+:thread+ (default)] Store the hub in thread-local storage. Correct for
thread-based servers (Puma, Unicorn) and background processors (Sidekiq,
Resque). Every fiber on a thread shares one hub.
[+:fiber+] Store the hub in Fiber Storage (Ruby 3.2+). Each fiber gets its
own hub, so concurrent requests on a fiber-based server (Falcon/async)
are isolated instead of sharing and corrupting one another's scope. A
fiber or thread started from another inherits its context and trace, but
its own scope changes stay local. Requested on a Ruby without Fiber
Storage (< 3.2), the SDK logs a warning and falls back to :thread.
412 413 414 |
# File 'lib/sentry/configuration.rb', line 412 def hub_isolation_level @hub_isolation_level end |
#include_local_variables ⇒ Boolean
Use #data_collection and stack_frame_variables instead.
Whether to capture local variables from the raised exception's frame. Default is false.
174 175 176 |
# File 'lib/sentry/configuration.rb', line 174 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
168 169 170 |
# File 'lib/sentry/configuration.rb', line 168 def inspect_exception_causes_for_exclusion @inspect_exception_causes_for_exclusion end |
#instrumenter ⇒ Symbol
The instrumenter to use, :sentry or :otel
329 330 331 |
# File 'lib/sentry/configuration.rb', line 329 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.
193 194 195 |
# File 'lib/sentry/configuration.rb', line 193 def linecache @linecache end |
#max_breadcrumbs ⇒ Integer
Max number of breadcrumbs a breadcrumb buffer can hold
133 134 135 |
# File 'lib/sentry/configuration.rb', line 133 def @max_breadcrumbs end |
#max_log_events ⇒ Integer
Maximum number of log events to buffer before sending
357 358 359 |
# File 'lib/sentry/configuration.rb', line 357 def max_log_events @max_log_events end |
#max_metric_events ⇒ Integer
Maximum number of metric events to buffer before sending
361 362 363 |
# File 'lib/sentry/configuration.rb', line 361 def max_metric_events @max_metric_events end |
#org_id ⇒ String?
An optional organization ID. The SDK will try to extract it from the DSN in most cases but you can provide it explicitly for self-hosted and Relay setups. This value is used for trace propagation and for features like strict_trace_continuation.
385 386 387 |
# File 'lib/sentry/configuration.rb', line 385 def org_id @org_id end |
#profiler_class ⇒ Class
The profiler class
333 334 335 |
# File 'lib/sentry/configuration.rb', line 333 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.
348 349 350 |
# File 'lib/sentry/configuration.rb', line 348 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.
339 340 341 |
# File 'lib/sentry/configuration.rb', line 339 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.
208 209 210 |
# File 'lib/sentry/configuration.rb', line 208 def project_root @project_root end |
#propagate_traces ⇒ Boolean
Insert sentry-trace to outgoing requests' headers
217 218 219 |
# File 'lib/sentry/configuration.rb', line 217 def propagate_traces @propagate_traces end |
#rack_env_whitelist ⇒ Array<String>
Use data_collection.http_headers.request to control request data collection instead.
Array of rack env parameters to be included in the event sent to sentry.
222 223 224 |
# File 'lib/sentry/configuration.rb', line 222 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.
227 228 229 |
# File 'lib/sentry/configuration.rb', line 227 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.
232 233 234 |
# File 'lib/sentry/configuration.rb', line 232 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.
203 204 205 |
# File 'lib/sentry/configuration.rb', line 203 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.
198 199 200 |
# File 'lib/sentry/configuration.rb', line 198 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
298 299 300 |
# File 'lib/sentry/configuration.rb', line 298 def send_client_reports @send_client_reports end |
#send_default_pii ⇒ Boolean
Use #data_collection instead.
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.
246 247 248 |
# File 'lib/sentry/configuration.rb', line 246 def send_default_pii @send_default_pii end |
#send_modules ⇒ Boolean
Include module versions in reports - boolean.
236 237 238 |
# File 'lib/sentry/configuration.rb', line 236 def send_modules @send_modules end |
#server_name ⇒ String
267 268 269 |
# File 'lib/sentry/configuration.rb', line 267 def server_name @server_name end |
#skip_rake_integration ⇒ Boolean
Allow to skip Sentry emails within rake tasks
261 262 263 |
# File 'lib/sentry/configuration.rb', line 261 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 http://localhost:8969/stream. If you want to use a different Sidecar proxy address, set this to String with the proxy URL.
187 188 189 |
# File 'lib/sentry/configuration.rb', line 187 def spotlight @spotlight end |
#std_lib_logger_filter ⇒ Proc?
Optional Proc, called to filter log messages before sending to Sentry
379 380 381 |
# File 'lib/sentry/configuration.rb', line 379 def std_lib_logger_filter @std_lib_logger_filter end |
#strict_trace_continuation ⇒ Boolean
If set to true, the SDK will only continue a trace if the org_id of the incoming trace found in the baggage header matches the org_id of the current Sentry client and only if BOTH are present.
If set to false, consistency of org_id will only be enforced if both are present. If either are missing, the trace will be continued.
The client's organization ID is extracted from the DSN or can be set with the org_id option. If the organization IDs do not match, the SDK will start a new trace instead of continuing the incoming one. This is useful to prevent traces of unknown third-party services from being continued in your application.
397 398 399 |
# File 'lib/sentry/configuration.rb', line 397 def strict_trace_continuation @strict_trace_continuation end |
#strip_backtrace_load_path ⇒ Boolean
Whether to strip the load path while constructing the backtrace frame filename. Defaults to true.
213 214 215 |
# File 'lib/sentry/configuration.rb', line 213 def strip_backtrace_load_path @strip_backtrace_load_path end |
#structured_logging ⇒ StructuredLoggingConfiguration (readonly)
Structured logging configuration.
293 294 295 |
# File 'lib/sentry/configuration.rb', line 293 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.
325 326 327 |
# File 'lib/sentry/configuration.rb', line 325 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 (/.*/)
313 314 315 |
# File 'lib/sentry/configuration.rb', line 313 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).
279 280 281 |
# File 'lib/sentry/configuration.rb', line 279 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.
289 290 291 |
# File 'lib/sentry/configuration.rb', line 289 def traces_sampler @traces_sampler end |
#transport ⇒ Transport::Configuration (readonly)
Transport related configuration.
271 272 273 |
# File 'lib/sentry/configuration.rb', line 271 def transport @transport end |
#trusted_proxies ⇒ Object
IP ranges for trusted proxies that will be skipped when calculating IP address.
264 265 266 |
# File 'lib/sentry/configuration.rb', line 264 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
473 474 475 |
# File 'lib/sentry/configuration.rb', line 473 def add_post_initialization_callback(&block) callbacks[:initialize][:after] << block end |
.after(event, &block) ⇒ Object
481 482 483 |
# File 'lib/sentry/configuration.rb', line 481 def after(event, &block) callbacks[event.to_sym][:after] << block end |
.before(event, &block) ⇒ Object
477 478 479 |
# File 'lib/sentry/configuration.rb', line 477 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
468 469 470 |
# File 'lib/sentry/configuration.rb', line 468 def post_initialization_callbacks @post_initialization_callbacks ||= [] end |
.validate(attribute, optional: false, type: nil) ⇒ Object
498 499 500 501 502 503 504 |
# File 'lib/sentry/configuration.rb', line 498 def validate(attribute, optional: false, type: nil) validations[attribute] = { optional: optional, type: type, proc: build_validation_proc(optional, type) } end |
.validations ⇒ Object
494 495 496 |
# File 'lib/sentry/configuration.rb', line 494 def validations @validations ||= {} end |
Instance Method Details
#csp_report_uri ⇒ String?
812 813 814 815 816 817 818 819 |
# File 'lib/sentry/configuration.rb', line 812 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.
842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/sentry/configuration.rb', line 842 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 |
#effective_org_id ⇒ String?
Returns the effective org ID, preferring the explicit config option over the DSN-parsed value.
753 754 755 |
# File 'lib/sentry/configuration.rb', line 753 def effective_org_id org_id || dsn&.org_id end |
#enabled_in_current_env? ⇒ Boolean
790 791 792 |
# File 'lib/sentry/configuration.rb', line 790 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.
855 856 857 858 |
# File 'lib/sentry/configuration.rb', line 855 def @errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first @errors.join(", ") end |
#exception_class_allowed?(exc) ⇒ Boolean
777 778 779 780 781 782 783 784 785 786 787 788 |
# File 'lib/sentry/configuration.rb', line 777 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 |
#log_deprecations ⇒ 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.
822 823 824 825 826 827 |
# File 'lib/sentry/configuration.rb', line 822 def log_deprecations log_warn("`send_default_pii` is deprecated; use `data_collection` instead.") if self.send_default_pii log_warn("`include_local_variables` is deprecated; use `data_collection.stack_frame_variables` instead.") if include_local_variables log_warn("`context_lines` is deprecated; use `data_collection.frame_context_lines` instead.") if context_lines != 3 log_warn("`rack_env_whitelist` is deprecated; use `data_collection.http_headers.request` to control request data collection instead.") if rack_env_whitelist != RACK_ENV_WHITELIST_DEFAULT end |
#profiling_enabled? ⇒ Boolean
805 806 807 808 809 |
# File 'lib/sentry/configuration.rb', line 805 def profiling_enabled? valid_sampler = !!(valid_sample_rate?(@profiles_sample_rate)) tracing_enabled? && valid_sampler && sending_allowed? end |
#run_after_close_callbacks ⇒ 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.
861 862 863 |
# File 'lib/sentry/configuration.rb', line 861 def run_after_close_callbacks run_callbacks(:after, :closed) end |
#sample_allowed? ⇒ Boolean
767 768 769 770 771 |
# File 'lib/sentry/configuration.rb', line 767 def sample_allowed? return true if sample_rate == 1.0 Random.rand < sample_rate end |
#sending_allowed? ⇒ Boolean
757 758 759 |
# File 'lib/sentry/configuration.rb', line 757 def sending_allowed? spotlight || sending_to_dsn_allowed? end |
#sending_to_dsn_allowed? ⇒ Boolean
761 762 763 764 765 |
# File 'lib/sentry/configuration.rb', line 761 def sending_to_dsn_allowed? @errors = [] valid? && capture_in_environment? end |
#session_tracking? ⇒ Boolean
773 774 775 |
# File 'lib/sentry/configuration.rb', line 773 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.
830 831 832 833 834 835 836 837 838 839 |
# File 'lib/sentry/configuration.rb', line 830 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
799 800 801 802 803 |
# File 'lib/sentry/configuration.rb', line 799 def tracing_enabled? valid_sampler = !!((valid_sample_rate?(@traces_sample_rate)) || @traces_sampler) valid_sampler && sending_allowed? end |
#valid_sample_rate?(sample_rate) ⇒ Boolean
794 795 796 797 |
# File 'lib/sentry/configuration.rb', line 794 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
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 |
# File 'lib/sentry/configuration.rb', line 611 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 |