sentry-ruby-core 4.8.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/Gemfile +3 -0
- data/README.md +2 -0
- data/lib/sentry/background_worker.rb +33 -3
- data/lib/sentry/backtrace.rb +1 -3
- data/lib/sentry/breadcrumb/sentry_logger.rb +2 -0
- data/lib/sentry/breadcrumb.rb +24 -3
- data/lib/sentry/breadcrumb_buffer.rb +16 -0
- data/lib/sentry/client.rb +38 -2
- data/lib/sentry/configuration.rb +94 -41
- data/lib/sentry/core_ext/object/deep_dup.rb +2 -0
- data/lib/sentry/core_ext/object/duplicable.rb +1 -0
- data/lib/sentry/dsn.rb +2 -0
- data/lib/sentry/envelope.rb +45 -0
- data/lib/sentry/event.rb +55 -18
- data/lib/sentry/exceptions.rb +2 -0
- data/lib/sentry/hub.rb +38 -2
- data/lib/sentry/integrable.rb +2 -0
- data/lib/sentry/interface.rb +3 -10
- data/lib/sentry/interfaces/exception.rb +14 -3
- data/lib/sentry/interfaces/request.rb +37 -20
- data/lib/sentry/interfaces/single_exception.rb +2 -0
- data/lib/sentry/interfaces/stacktrace.rb +6 -0
- data/lib/sentry/interfaces/stacktrace_builder.rb +39 -10
- data/lib/sentry/interfaces/threads.rb +12 -2
- data/lib/sentry/linecache.rb +3 -0
- data/lib/sentry/net/http.rb +54 -65
- data/lib/sentry/rack/capture_exceptions.rb +28 -24
- data/lib/sentry/rack.rb +2 -0
- data/lib/sentry/rake.rb +16 -6
- data/lib/sentry/redis.rb +90 -0
- data/lib/sentry/release_detector.rb +3 -0
- data/lib/sentry/scope.rb +85 -6
- data/lib/sentry/session.rb +35 -0
- data/lib/sentry/session_flusher.rb +79 -0
- data/lib/sentry/span.rb +84 -8
- data/lib/sentry/transaction.rb +48 -14
- data/lib/sentry/transaction_event.rb +8 -0
- data/lib/sentry/transport/configuration.rb +3 -2
- data/lib/sentry/transport/dummy_transport.rb +8 -1
- data/lib/sentry/transport/http_transport.rb +55 -42
- data/lib/sentry/transport.rb +79 -37
- data/lib/sentry/utils/argument_checking_helper.rb +2 -0
- data/lib/sentry/utils/custom_inspection.rb +2 -0
- data/lib/sentry/utils/exception_cause_chain.rb +2 -0
- data/lib/sentry/utils/logging_helper.rb +6 -4
- data/lib/sentry/utils/real_ip.rb +2 -0
- data/lib/sentry/utils/request_id.rb +2 -0
- data/lib/sentry/version.rb +3 -1
- data/lib/sentry-ruby.rb +212 -41
- data/sentry-ruby-core.gemspec +0 -1
- data/sentry-ruby.gemspec +0 -1
- metadata +7 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6a629d8aa998cef5638cd40e3dc9e0ad24770d0c31540b327c669e9fb84aedd
|
4
|
+
data.tar.gz: e373b601b401fddca9307a32ea1dda36bc4994209c68b19748e89f128a598e80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cfd2f1fe582578b74bc23610931d95bf7a86c35c696c658d55fb4f40ddfdd129c36bae415bc73efef20ecfb435f33ba72e3b46a96f536c0c61692d8c8cb34e2
|
7
|
+
data.tar.gz: f10f71edc8bef7a57426de73e0cf2a1aea855c89ec2900a065986d33f064216f7da74c0cf9f7dd41c08dcb18224a61c6c43bad67548a327ca593b73b526e3d8a
|
data/.yardopts
ADDED
data/Gemfile
CHANGED
@@ -9,6 +9,7 @@ gem "rake", "~> 12.0"
|
|
9
9
|
gem "rspec", "~> 3.0"
|
10
10
|
gem "rspec-retry"
|
11
11
|
gem "webmock"
|
12
|
+
gem "fakeredis"
|
12
13
|
gem "timecop"
|
13
14
|
gem 'simplecov'
|
14
15
|
gem "simplecov-cobertura", "~> 1.4"
|
@@ -22,3 +23,5 @@ gem "benchmark-ips"
|
|
22
23
|
gem "benchmark_driver"
|
23
24
|
gem "benchmark-ipsa"
|
24
25
|
gem "benchmark-memory"
|
26
|
+
|
27
|
+
gem "yard", "~> 0.9.27"
|
data/README.md
CHANGED
@@ -78,6 +78,8 @@ end
|
|
78
78
|
|
79
79
|
To learn more about sampling transactions, please visit the [official documentation](https://docs.sentry.io/platforms/ruby/configuration/sampling/#configuring-the-transaction-sample-rate).
|
80
80
|
|
81
|
+
### [Migration Guide](https://docs.sentry.io/platforms/ruby/migration/)
|
82
|
+
|
81
83
|
### Integrations
|
82
84
|
|
83
85
|
- [Rack](https://docs.sentry.io/platforms/ruby/guides/rack/)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "concurrent/executor/thread_pool_executor"
|
2
4
|
require "concurrent/executor/immediate_executor"
|
3
5
|
require "concurrent/configuration"
|
@@ -6,12 +8,18 @@ module Sentry
|
|
6
8
|
class BackgroundWorker
|
7
9
|
include LoggingHelper
|
8
10
|
|
9
|
-
attr_reader :max_queue, :number_of_threads
|
11
|
+
attr_reader :max_queue, :number_of_threads
|
12
|
+
# @deprecated Use Sentry.logger to retrieve the current logger instead.
|
13
|
+
attr_reader :logger
|
14
|
+
attr_accessor :shutdown_timeout
|
10
15
|
|
11
16
|
def initialize(configuration)
|
12
17
|
@max_queue = 30
|
18
|
+
@shutdown_timeout = 1
|
13
19
|
@number_of_threads = configuration.background_worker_threads
|
14
20
|
@logger = configuration.logger
|
21
|
+
@debug = configuration.debug
|
22
|
+
@shutdown_callback = nil
|
15
23
|
|
16
24
|
@executor =
|
17
25
|
if configuration.async
|
@@ -23,19 +31,41 @@ module Sentry
|
|
23
31
|
else
|
24
32
|
log_debug("initialized a background worker with #{@number_of_threads} threads")
|
25
33
|
|
26
|
-
Concurrent::ThreadPoolExecutor.new(
|
34
|
+
executor = Concurrent::ThreadPoolExecutor.new(
|
27
35
|
min_threads: 0,
|
28
36
|
max_threads: @number_of_threads,
|
29
37
|
max_queue: @max_queue,
|
30
38
|
fallback_policy: :discard
|
31
39
|
)
|
40
|
+
|
41
|
+
@shutdown_callback = proc do
|
42
|
+
executor.shutdown
|
43
|
+
executor.wait_for_termination(@shutdown_timeout)
|
44
|
+
end
|
45
|
+
|
46
|
+
executor
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
50
|
+
# if you want to monkey-patch this method, please override `_perform` instead
|
35
51
|
def perform(&block)
|
36
52
|
@executor.post do
|
37
|
-
|
53
|
+
begin
|
54
|
+
_perform(&block)
|
55
|
+
rescue Exception => e
|
56
|
+
log_error("exception happened in background worker", e, debug: @debug)
|
57
|
+
end
|
38
58
|
end
|
39
59
|
end
|
60
|
+
|
61
|
+
def shutdown
|
62
|
+
@shutdown_callback&.call
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def _perform(&block)
|
68
|
+
block.call
|
69
|
+
end
|
40
70
|
end
|
41
71
|
end
|
data/lib/sentry/backtrace.rb
CHANGED
data/lib/sentry/breadcrumb.rb
CHANGED
@@ -1,10 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Sentry
|
2
4
|
class Breadcrumb
|
3
5
|
DATA_SERIALIZATION_ERROR_MESSAGE = "[data were removed due to serialization issues]"
|
4
6
|
|
5
|
-
|
7
|
+
# @return [String, nil]
|
8
|
+
attr_accessor :category
|
9
|
+
# @return [Hash, nil]
|
10
|
+
attr_accessor :data
|
11
|
+
# @return [String, nil]
|
12
|
+
attr_accessor :level
|
13
|
+
# @return [Time, Integer, nil]
|
14
|
+
attr_accessor :timestamp
|
15
|
+
# @return [String, nil]
|
16
|
+
attr_accessor :type
|
17
|
+
# @return [String, nil]
|
6
18
|
attr_reader :message
|
7
19
|
|
20
|
+
# @param category [String, nil]
|
21
|
+
# @param data [Hash, nil]
|
22
|
+
# @param message [String, nil]
|
23
|
+
# @param timestamp [Time, Integer, nil]
|
24
|
+
# @param level [String, nil]
|
25
|
+
# @param type [String, nil]
|
8
26
|
def initialize(category: nil, data: nil, message: nil, timestamp: nil, level: nil, type: nil)
|
9
27
|
@category = category
|
10
28
|
@data = data || {}
|
@@ -14,6 +32,7 @@ module Sentry
|
|
14
32
|
self.message = message
|
15
33
|
end
|
16
34
|
|
35
|
+
# @return [Hash]
|
17
36
|
def to_hash
|
18
37
|
{
|
19
38
|
category: @category,
|
@@ -25,8 +44,10 @@ module Sentry
|
|
25
44
|
}
|
26
45
|
end
|
27
46
|
|
28
|
-
|
29
|
-
|
47
|
+
# @param message [String]
|
48
|
+
# @return [void]
|
49
|
+
def message=(message)
|
50
|
+
@message = (message || "").byteslice(0..Event::MAX_MESSAGE_SIZE_IN_BYTES)
|
30
51
|
end
|
31
52
|
|
32
53
|
private
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "sentry/breadcrumb"
|
2
4
|
|
3
5
|
module Sentry
|
@@ -5,40 +7,54 @@ module Sentry
|
|
5
7
|
DEFAULT_SIZE = 100
|
6
8
|
include Enumerable
|
7
9
|
|
10
|
+
# @return [Array]
|
8
11
|
attr_accessor :buffer
|
9
12
|
|
13
|
+
# @param size [Integer, nil] If it's not provided, it'll fallback to DEFAULT_SIZE
|
10
14
|
def initialize(size = nil)
|
11
15
|
@buffer = Array.new(size || DEFAULT_SIZE)
|
12
16
|
end
|
13
17
|
|
18
|
+
# @param crumb [Breadcrumb]
|
19
|
+
# @return [void]
|
14
20
|
def record(crumb)
|
15
21
|
yield(crumb) if block_given?
|
16
22
|
@buffer.slice!(0)
|
17
23
|
@buffer << crumb
|
18
24
|
end
|
19
25
|
|
26
|
+
# @return [Array]
|
20
27
|
def members
|
21
28
|
@buffer.compact
|
22
29
|
end
|
23
30
|
|
31
|
+
# Returns the last breadcrumb stored in the buffer. If the buffer it's empty, it returns nil.
|
32
|
+
# @return [Breadcrumb, nil]
|
24
33
|
def peek
|
25
34
|
members.last
|
26
35
|
end
|
27
36
|
|
37
|
+
# Iterates through all breadcrumbs.
|
38
|
+
# @param block [Proc]
|
39
|
+
# @yieldparam crumb [Breadcrumb]
|
40
|
+
# @return [Array]
|
28
41
|
def each(&block)
|
29
42
|
members.each(&block)
|
30
43
|
end
|
31
44
|
|
45
|
+
# @return [Boolean]
|
32
46
|
def empty?
|
33
47
|
members.none?
|
34
48
|
end
|
35
49
|
|
50
|
+
# @return [Hash]
|
36
51
|
def to_hash
|
37
52
|
{
|
38
53
|
values: members.map(&:to_hash)
|
39
54
|
}
|
40
55
|
end
|
41
56
|
|
57
|
+
# @return [BreadcrumbBuffer]
|
42
58
|
def dup
|
43
59
|
copy = super
|
44
60
|
copy.buffer = buffer.deep_dup
|
data/lib/sentry/client.rb
CHANGED
@@ -1,11 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "sentry/transport"
|
2
4
|
|
3
5
|
module Sentry
|
4
6
|
class Client
|
5
7
|
include LoggingHelper
|
6
8
|
|
7
|
-
|
9
|
+
# The Transport object that'll send events for the client.
|
10
|
+
# @return [Transport]
|
11
|
+
attr_reader :transport
|
12
|
+
|
13
|
+
# @!macro configuration
|
14
|
+
attr_reader :configuration
|
15
|
+
|
16
|
+
# @deprecated Use Sentry.logger to retrieve the current logger instead.
|
17
|
+
attr_reader :logger
|
8
18
|
|
19
|
+
# @param configuration [Configuration]
|
9
20
|
def initialize(configuration)
|
10
21
|
@configuration = configuration
|
11
22
|
@logger = configuration.logger
|
@@ -23,6 +34,11 @@ module Sentry
|
|
23
34
|
end
|
24
35
|
end
|
25
36
|
|
37
|
+
# Applies the given scope's data to the event and sends it to Sentry.
|
38
|
+
# @param event [Event] the event to be sent.
|
39
|
+
# @param scope [Scope] the scope with contextual data that'll be applied to the event before it's sent.
|
40
|
+
# @param hint [Hash] the hint data that'll be passed to `before_send` callback and the scope's event processors.
|
41
|
+
# @return [Event, nil]
|
26
42
|
def capture_event(event, scope, hint = {})
|
27
43
|
return unless configuration.sending_allowed?
|
28
44
|
|
@@ -55,9 +71,14 @@ module Sentry
|
|
55
71
|
nil
|
56
72
|
end
|
57
73
|
|
74
|
+
# Initializes an Event object with the given exception. Returns `nil` if the exception's class is excluded from reporting.
|
75
|
+
# @param exception [Exception] the exception to be reported.
|
76
|
+
# @param hint [Hash] the hint data that'll be passed to `before_send` callback and the scope's event processors.
|
77
|
+
# @return [Event, nil]
|
58
78
|
def event_from_exception(exception, hint = {})
|
79
|
+
return unless @configuration.sending_allowed? && @configuration.exception_class_allowed?(exception)
|
80
|
+
|
59
81
|
integration_meta = Sentry.integrations[hint[:integration]]
|
60
|
-
return unless @configuration.exception_class_allowed?(exception)
|
61
82
|
|
62
83
|
Event.new(configuration: configuration, integration_meta: integration_meta).tap do |event|
|
63
84
|
event.add_exception_interface(exception)
|
@@ -65,25 +86,36 @@ module Sentry
|
|
65
86
|
end
|
66
87
|
end
|
67
88
|
|
89
|
+
# Initializes an Event object with the given message.
|
90
|
+
# @param message [String] the message to be reported.
|
91
|
+
# @param hint [Hash] the hint data that'll be passed to `before_send` callback and the scope's event processors.
|
92
|
+
# @return [Event]
|
68
93
|
def event_from_message(message, hint = {}, backtrace: nil)
|
94
|
+
return unless @configuration.sending_allowed?
|
95
|
+
|
69
96
|
integration_meta = Sentry.integrations[hint[:integration]]
|
70
97
|
event = Event.new(configuration: configuration, integration_meta: integration_meta, message: message)
|
71
98
|
event.add_threads_interface(backtrace: backtrace || caller)
|
72
99
|
event
|
73
100
|
end
|
74
101
|
|
102
|
+
# Initializes an Event object with the given Transaction object.
|
103
|
+
# @param transaction [Transaction] the transaction to be recorded.
|
104
|
+
# @return [TransactionEvent]
|
75
105
|
def event_from_transaction(transaction)
|
76
106
|
TransactionEvent.new(configuration: configuration).tap do |event|
|
77
107
|
event.transaction = transaction.name
|
78
108
|
event.contexts.merge!(trace: transaction.get_trace_context)
|
79
109
|
event.timestamp = transaction.timestamp
|
80
110
|
event.start_timestamp = transaction.start_timestamp
|
111
|
+
event.tags = transaction.tags
|
81
112
|
|
82
113
|
finished_spans = transaction.span_recorder.spans.select { |span| span.timestamp && span != transaction }
|
83
114
|
event.spans = finished_spans.map(&:to_hash)
|
84
115
|
end
|
85
116
|
end
|
86
117
|
|
118
|
+
# @!macro send_event
|
87
119
|
def send_event(event, hint = nil)
|
88
120
|
event_type = event.is_a?(Event) ? event.type : event["type"]
|
89
121
|
|
@@ -110,6 +142,10 @@ module Sentry
|
|
110
142
|
raise
|
111
143
|
end
|
112
144
|
|
145
|
+
# Generates a Sentry trace for distribted tracing from the given Span.
|
146
|
+
# Returns `nil` if `config.propagate_traces` is `false`.
|
147
|
+
# @param span [Span] the span to generate trace from.
|
148
|
+
# @return [String, nil]
|
113
149
|
def generate_sentry_trace(span)
|
114
150
|
return unless configuration.propagate_traces
|
115
151
|
|
data/lib/sentry/configuration.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "concurrent/utility/processor_counter"
|
2
4
|
|
3
5
|
require "sentry/utils/exception_cause_chain"
|
@@ -15,10 +17,15 @@ module Sentry
|
|
15
17
|
# Directories to be recognized as part of your app. e.g. if you
|
16
18
|
# have an `engines` dir at the root of your project, you may want
|
17
19
|
# to set this to something like /(app|config|engines|lib)/
|
20
|
+
#
|
21
|
+
# @return [Regexp, nil]
|
18
22
|
attr_accessor :app_dirs_pattern
|
19
23
|
|
20
24
|
# Provide an object that responds to `call` to send events asynchronously.
|
21
25
|
# E.g.: lambda { |event| Thread.new { Sentry.send_event(event) } }
|
26
|
+
#
|
27
|
+
# @deprecated It will be removed in the next major release. Please read https://github.com/getsentry/sentry-ruby/issues/1522 for more information
|
28
|
+
# @return [Proc, nil]
|
22
29
|
attr_reader :async
|
23
30
|
|
24
31
|
# to send events in a non-blocking way, sentry-ruby has its own background worker
|
@@ -28,143 +35,184 @@ module Sentry
|
|
28
35
|
#
|
29
36
|
# if you want to send events synchronously, set the value to 0
|
30
37
|
# E.g.: config.background_worker_threads = 0
|
38
|
+
# @return [Integer]
|
31
39
|
attr_accessor :background_worker_threads
|
32
40
|
|
33
41
|
# a proc/lambda that takes an array of stack traces
|
34
42
|
# it'll be used to silence (reduce) backtrace of the exception
|
35
43
|
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# Rails.backtrace_cleaner.clean(backtrace)
|
41
|
-
# end
|
42
|
-
# ```
|
44
|
+
# @example
|
45
|
+
# config.backtrace_cleanup_callback = lambda do |backtrace|
|
46
|
+
# Rails.backtrace_cleaner.clean(backtrace)
|
47
|
+
# end
|
43
48
|
#
|
49
|
+
# @return [Proc, nil]
|
44
50
|
attr_accessor :backtrace_cleanup_callback
|
45
51
|
|
46
52
|
# Optional Proc, called before adding the breadcrumb to the current scope
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
+
# @example
|
54
|
+
# config.before = lambda do |breadcrumb, hint|
|
55
|
+
# breadcrumb.message = 'a'
|
56
|
+
# breadcrumb
|
57
|
+
# end
|
58
|
+
# @return [Proc]
|
53
59
|
attr_reader :before_breadcrumb
|
54
60
|
|
55
|
-
# Optional Proc, called before sending an event to the server
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
61
|
+
# Optional Proc, called before sending an event to the server
|
62
|
+
# @example
|
63
|
+
# config.before_send = lambda do |event, hint|
|
64
|
+
# # skip ZeroDivisionError exceptions
|
65
|
+
# # note: hint[:exception] would be a String if you use async callback
|
66
|
+
# if hint[:exception].is_a?(ZeroDivisionError)
|
67
|
+
# nil
|
68
|
+
# else
|
69
|
+
# event
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
# @return [Proc]
|
62
73
|
attr_reader :before_send
|
63
74
|
|
64
75
|
# An array of breadcrumbs loggers to be used. Available options are:
|
65
76
|
# - :sentry_logger
|
77
|
+
# - :http_logger
|
78
|
+
# - :redis_logger
|
79
|
+
#
|
80
|
+
# And if you also use sentry-rails:
|
66
81
|
# - :active_support_logger
|
82
|
+
# - :monotonic_active_support_logger
|
83
|
+
#
|
84
|
+
# @return [Array<Symbol>]
|
67
85
|
attr_reader :breadcrumbs_logger
|
68
86
|
|
69
87
|
# Whether to capture local variables from the raised exception's frame. Default is false.
|
88
|
+
# @return [Boolean]
|
70
89
|
attr_accessor :capture_exception_frame_locals
|
71
90
|
|
72
91
|
# Max number of breadcrumbs a breadcrumb buffer can hold
|
92
|
+
# @return [Integer]
|
73
93
|
attr_accessor :max_breadcrumbs
|
74
94
|
|
75
95
|
# Number of lines of code context to capture, or nil for none
|
96
|
+
# @return [Integer, nil]
|
76
97
|
attr_accessor :context_lines
|
77
98
|
|
78
99
|
# RACK_ENV by default.
|
100
|
+
# @return [String]
|
79
101
|
attr_reader :environment
|
80
102
|
|
81
103
|
# Whether the SDK should run in the debugging mode. Default is false.
|
82
104
|
# If set to true, SDK errors will be logged with backtrace
|
105
|
+
# @return [Boolean]
|
83
106
|
attr_accessor :debug
|
84
107
|
|
85
108
|
# the dsn value, whether it's set via `config.dsn=` or `ENV["SENTRY_DSN"]`
|
109
|
+
# @return [String]
|
86
110
|
attr_reader :dsn
|
87
111
|
|
88
112
|
# Whitelist of enabled_environments that will send notifications to Sentry. Array of Strings.
|
113
|
+
# @return [Array<String>]
|
89
114
|
attr_accessor :enabled_environments
|
90
115
|
|
91
116
|
# Logger 'progname's to exclude from breadcrumbs
|
117
|
+
# @return [Array<String>]
|
92
118
|
attr_accessor :exclude_loggers
|
93
119
|
|
94
120
|
# Array of exception classes that should never be sent. See IGNORE_DEFAULT.
|
95
121
|
# You should probably append to this rather than overwrite it.
|
122
|
+
# @return [Array<String>]
|
96
123
|
attr_accessor :excluded_exceptions
|
97
124
|
|
98
125
|
# Boolean to check nested exceptions when deciding if to exclude. Defaults to true
|
126
|
+
# @return [Boolean]
|
99
127
|
attr_accessor :inspect_exception_causes_for_exclusion
|
100
128
|
alias inspect_exception_causes_for_exclusion? inspect_exception_causes_for_exclusion
|
101
129
|
|
102
130
|
# You may provide your own LineCache for matching paths with source files.
|
103
|
-
# This may be useful if you need to get source code from places other than
|
104
|
-
#
|
131
|
+
# This may be useful if you need to get source code from places other than the disk.
|
132
|
+
# @see LineCache
|
133
|
+
# @return [LineCache]
|
105
134
|
attr_accessor :linecache
|
106
135
|
|
107
136
|
# Logger used by Sentry. In Rails, this is the Rails logger, otherwise
|
108
137
|
# Sentry provides its own Sentry::Logger.
|
138
|
+
# @return [Logger]
|
109
139
|
attr_accessor :logger
|
110
140
|
|
111
141
|
# Project directory root for in_app detection. Could be Rails root, etc.
|
112
142
|
# Set automatically for Rails.
|
143
|
+
# @return [String]
|
113
144
|
attr_accessor :project_root
|
114
145
|
|
115
146
|
# Insert sentry-trace to outgoing requests' headers
|
147
|
+
# @return [Boolean]
|
116
148
|
attr_accessor :propagate_traces
|
117
149
|
|
118
150
|
# Array of rack env parameters to be included in the event sent to sentry.
|
151
|
+
# @return [Array<String>]
|
119
152
|
attr_accessor :rack_env_whitelist
|
120
153
|
|
121
154
|
# Release tag to be passed with every event sent to Sentry.
|
122
155
|
# We automatically try to set this to a git SHA or Capistrano release.
|
156
|
+
# @return [String]
|
123
157
|
attr_accessor :release
|
124
158
|
|
125
159
|
# The sampling factor to apply to events. A value of 0.0 will not send
|
126
160
|
# any events, and a value of 1.0 will send 100% of events.
|
161
|
+
# @return [Float]
|
127
162
|
attr_accessor :sample_rate
|
128
163
|
|
129
164
|
# Include module versions in reports - boolean.
|
165
|
+
# @return [Boolean]
|
130
166
|
attr_accessor :send_modules
|
131
167
|
|
132
168
|
# When send_default_pii's value is false (default), sensitive information like
|
133
169
|
# - user ip
|
134
170
|
# - user cookie
|
135
171
|
# - request body
|
172
|
+
# - query string
|
136
173
|
# will not be sent to Sentry.
|
174
|
+
# @return [Boolean]
|
137
175
|
attr_accessor :send_default_pii
|
138
176
|
|
139
177
|
# Allow to skip Sentry emails within rake tasks
|
178
|
+
# @return [Boolean]
|
140
179
|
attr_accessor :skip_rake_integration
|
141
180
|
|
142
181
|
# IP ranges for trusted proxies that will be skipped when calculating IP address.
|
143
182
|
attr_accessor :trusted_proxies
|
144
183
|
|
184
|
+
# @return [String]
|
145
185
|
attr_accessor :server_name
|
146
186
|
|
147
187
|
# Return a Transport::Configuration object for transport-related configurations.
|
188
|
+
# @return [Transport]
|
148
189
|
attr_reader :transport
|
149
190
|
|
150
191
|
# Take a float between 0.0 and 1.0 as the sample rate for tracing events (transactions).
|
192
|
+
# @return [Float]
|
151
193
|
attr_accessor :traces_sample_rate
|
152
194
|
|
153
195
|
# Take a Proc that controls the sample rate for every tracing event, e.g.
|
154
|
-
#
|
155
|
-
# lambda do |tracing_context|
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
196
|
+
# @example
|
197
|
+
# config.traces_sampler = lambda do |tracing_context|
|
198
|
+
# # tracing_context[:transaction_context] contains the information about the transaction
|
199
|
+
# # tracing_context[:parent_sampled] contains the transaction's parent's sample decision
|
200
|
+
# true # return value can be a boolean or a float between 0.0 and 1.0
|
201
|
+
# end
|
202
|
+
# @return [Proc]
|
161
203
|
attr_accessor :traces_sampler
|
162
204
|
|
163
205
|
# Send diagnostic client reports about dropped events, true by default
|
164
206
|
# tries to attach to an existing envelope max once every 30s
|
207
|
+
# @return [Boolean]
|
165
208
|
attr_accessor :send_client_reports
|
166
209
|
|
210
|
+
# Track sessions in request/response cycles automatically
|
211
|
+
# @return [Boolean]
|
212
|
+
attr_accessor :auto_session_tracking
|
213
|
+
|
167
214
|
# these are not config options
|
215
|
+
# @!visibility private
|
168
216
|
attr_reader :errors, :gem_specs
|
169
217
|
|
170
218
|
# Most of these errors generate 4XX responses. In general, Sentry clients
|
@@ -217,6 +265,7 @@ module Sentry
|
|
217
265
|
self.send_default_pii = false
|
218
266
|
self.skip_rake_integration = false
|
219
267
|
self.send_client_reports = true
|
268
|
+
self.auto_session_tracking = true
|
220
269
|
self.trusted_proxies = []
|
221
270
|
self.dsn = ENV['SENTRY_DSN']
|
222
271
|
self.server_name = server_name_from_env
|
@@ -285,11 +334,6 @@ module Sentry
|
|
285
334
|
Random.rand < sample_rate
|
286
335
|
end
|
287
336
|
|
288
|
-
def error_messages
|
289
|
-
@errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first
|
290
|
-
@errors.join(", ")
|
291
|
-
end
|
292
|
-
|
293
337
|
def exception_class_allowed?(exc)
|
294
338
|
if exc.is_a?(Sentry::Error)
|
295
339
|
# Try to prevent error reporting loops
|
@@ -311,6 +355,17 @@ module Sentry
|
|
311
355
|
!!((@traces_sample_rate && @traces_sample_rate >= 0.0 && @traces_sample_rate <= 1.0) || @traces_sampler) && sending_allowed?
|
312
356
|
end
|
313
357
|
|
358
|
+
# @return [String, nil]
|
359
|
+
def csp_report_uri
|
360
|
+
if dsn && dsn.valid?
|
361
|
+
uri = dsn.csp_report_uri
|
362
|
+
uri += "&sentry_release=#{CGI.escape(release)}" if release && !release.empty?
|
363
|
+
uri += "&sentry_environment=#{CGI.escape(environment)}" if environment && !environment.empty?
|
364
|
+
uri
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
# @api private
|
314
369
|
def stacktrace_builder
|
315
370
|
@stacktrace_builder ||= StacktraceBuilder.new(
|
316
371
|
project_root: @project_root.to_s,
|
@@ -321,6 +376,7 @@ module Sentry
|
|
321
376
|
)
|
322
377
|
end
|
323
378
|
|
379
|
+
# @api private
|
324
380
|
def detect_release
|
325
381
|
return unless sending_allowed?
|
326
382
|
|
@@ -333,13 +389,10 @@ module Sentry
|
|
333
389
|
log_error("Error detecting release", e, debug: debug)
|
334
390
|
end
|
335
391
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
uri += "&sentry_environment=#{CGI.escape(environment)}" if environment && !environment.empty?
|
341
|
-
uri
|
342
|
-
end
|
392
|
+
# @api private
|
393
|
+
def error_messages
|
394
|
+
@errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first
|
395
|
+
@errors.join(", ")
|
343
396
|
end
|
344
397
|
|
345
398
|
private
|