sentry-ruby-core 4.8.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -0
- data/Gemfile +3 -0
- data/README.md +2 -0
- data/lib/sentry/background_worker.rb +3 -1
- data/lib/sentry/backtrace.rb +1 -3
- data/lib/sentry/breadcrumb.rb +22 -3
- data/lib/sentry/breadcrumb_buffer.rb +14 -0
- data/lib/sentry/client.rb +36 -2
- data/lib/sentry/configuration.rb +87 -41
- data/lib/sentry/envelope.rb +1 -0
- data/lib/sentry/event.rb +54 -18
- data/lib/sentry/hub.rb +7 -1
- data/lib/sentry/interface.rb +1 -10
- data/lib/sentry/interfaces/exception.rb +11 -3
- data/lib/sentry/interfaces/request.rb +37 -20
- data/lib/sentry/interfaces/stacktrace.rb +4 -0
- data/lib/sentry/interfaces/stacktrace_builder.rb +37 -10
- data/lib/sentry/interfaces/threads.rb +10 -2
- data/lib/sentry/linecache.rb +1 -0
- data/lib/sentry/net/http.rb +52 -65
- data/lib/sentry/rake.rb +12 -2
- data/lib/sentry/redis.rb +88 -0
- data/lib/sentry/release_detector.rb +1 -0
- data/lib/sentry/scope.rb +67 -1
- data/lib/sentry/span.rb +83 -8
- data/lib/sentry/transaction.rb +46 -14
- data/lib/sentry/transaction_event.rb +8 -0
- data/lib/sentry/transport/configuration.rb +1 -2
- data/lib/sentry/transport/http_transport.rb +50 -39
- data/lib/sentry/transport.rb +4 -1
- data/lib/sentry/utils/logging_helper.rb +4 -4
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +165 -41
- data/sentry-ruby-core.gemspec +0 -1
- data/sentry-ruby.gemspec +0 -1
- metadata +4 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8b9d0c43497ccc151613d208b6e9a51489586a41cbb7849cbcfcd3e5795765f
|
4
|
+
data.tar.gz: 79e7e9f621b2fe8bfc1c1dc292a16392e499925c13bdc1c31c3f8e05240f42e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3def5710a658f0365dbe11292f548aafcaf6d467d04abd5e0973035c5c3243307d49347b829ae0aa93d459c2bf4036813ec2a4589471c8da21d438318144c0aa
|
7
|
+
data.tar.gz: 99eab89037a4e468c7bb257d33aaf85ec8830102aa233a9af4c5091c92d67726f4ffab47b3eeedba07f079b4b3600145458e9283274532b534824acd21236617
|
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/)
|
@@ -8,7 +8,9 @@ module Sentry
|
|
8
8
|
class BackgroundWorker
|
9
9
|
include LoggingHelper
|
10
10
|
|
11
|
-
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
|
12
14
|
attr_accessor :shutdown_timeout
|
13
15
|
|
14
16
|
def initialize(configuration)
|
data/lib/sentry/backtrace.rb
CHANGED
data/lib/sentry/breadcrumb.rb
CHANGED
@@ -4,9 +4,25 @@ module Sentry
|
|
4
4
|
class Breadcrumb
|
5
5
|
DATA_SERIALIZATION_ERROR_MESSAGE = "[data were removed due to serialization issues]"
|
6
6
|
|
7
|
-
|
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]
|
8
18
|
attr_reader :message
|
9
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]
|
10
26
|
def initialize(category: nil, data: nil, message: nil, timestamp: nil, level: nil, type: nil)
|
11
27
|
@category = category
|
12
28
|
@data = data || {}
|
@@ -16,6 +32,7 @@ module Sentry
|
|
16
32
|
self.message = message
|
17
33
|
end
|
18
34
|
|
35
|
+
# @return [Hash]
|
19
36
|
def to_hash
|
20
37
|
{
|
21
38
|
category: @category,
|
@@ -27,8 +44,10 @@ module Sentry
|
|
27
44
|
}
|
28
45
|
end
|
29
46
|
|
30
|
-
|
31
|
-
|
47
|
+
# @param message [String]
|
48
|
+
# @return [void]
|
49
|
+
def message=(message)
|
50
|
+
@message = (message || "").byteslice(0..Event::MAX_MESSAGE_SIZE_IN_BYTES)
|
32
51
|
end
|
33
52
|
|
34
53
|
private
|
@@ -7,40 +7,54 @@ module Sentry
|
|
7
7
|
DEFAULT_SIZE = 100
|
8
8
|
include Enumerable
|
9
9
|
|
10
|
+
# @return [Array]
|
10
11
|
attr_accessor :buffer
|
11
12
|
|
13
|
+
# @param size [Integer, nil] If it's not provided, it'll fallback to DEFAULT_SIZE
|
12
14
|
def initialize(size = nil)
|
13
15
|
@buffer = Array.new(size || DEFAULT_SIZE)
|
14
16
|
end
|
15
17
|
|
18
|
+
# @param crumb [Breadcrumb]
|
19
|
+
# @return [void]
|
16
20
|
def record(crumb)
|
17
21
|
yield(crumb) if block_given?
|
18
22
|
@buffer.slice!(0)
|
19
23
|
@buffer << crumb
|
20
24
|
end
|
21
25
|
|
26
|
+
# @return [Array]
|
22
27
|
def members
|
23
28
|
@buffer.compact
|
24
29
|
end
|
25
30
|
|
31
|
+
# Returns the last breadcrumb stored in the buffer. If the buffer it's empty, it returns nil.
|
32
|
+
# @return [Breadcrumb, nil]
|
26
33
|
def peek
|
27
34
|
members.last
|
28
35
|
end
|
29
36
|
|
37
|
+
# Iterates through all breadcrumbs.
|
38
|
+
# @param block [Proc]
|
39
|
+
# @yieldparam crumb [Breadcrumb]
|
40
|
+
# @return [Array]
|
30
41
|
def each(&block)
|
31
42
|
members.each(&block)
|
32
43
|
end
|
33
44
|
|
45
|
+
# @return [Boolean]
|
34
46
|
def empty?
|
35
47
|
members.none?
|
36
48
|
end
|
37
49
|
|
50
|
+
# @return [Hash]
|
38
51
|
def to_hash
|
39
52
|
{
|
40
53
|
values: members.map(&:to_hash)
|
41
54
|
}
|
42
55
|
end
|
43
56
|
|
57
|
+
# @return [BreadcrumbBuffer]
|
44
58
|
def dup
|
45
59
|
copy = super
|
46
60
|
copy.buffer = buffer.deep_dup
|
data/lib/sentry/client.rb
CHANGED
@@ -6,8 +6,17 @@ module Sentry
|
|
6
6
|
class Client
|
7
7
|
include LoggingHelper
|
8
8
|
|
9
|
-
|
9
|
+
# The Transport object that'll send events for the client.
|
10
|
+
# @return [Transport]
|
11
|
+
attr_reader :transport
|
10
12
|
|
13
|
+
# @!macro configuration
|
14
|
+
attr_reader :configuration
|
15
|
+
|
16
|
+
# @deprecated Use Sentry.logger to retrieve the current logger instead.
|
17
|
+
attr_reader :logger
|
18
|
+
|
19
|
+
# @param configuration [Configuration]
|
11
20
|
def initialize(configuration)
|
12
21
|
@configuration = configuration
|
13
22
|
@logger = configuration.logger
|
@@ -25,6 +34,11 @@ module Sentry
|
|
25
34
|
end
|
26
35
|
end
|
27
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]
|
28
42
|
def capture_event(event, scope, hint = {})
|
29
43
|
return unless configuration.sending_allowed?
|
30
44
|
|
@@ -57,9 +71,14 @@ module Sentry
|
|
57
71
|
nil
|
58
72
|
end
|
59
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]
|
60
78
|
def event_from_exception(exception, hint = {})
|
79
|
+
return unless @configuration.sending_allowed? && @configuration.exception_class_allowed?(exception)
|
80
|
+
|
61
81
|
integration_meta = Sentry.integrations[hint[:integration]]
|
62
|
-
return unless @configuration.exception_class_allowed?(exception)
|
63
82
|
|
64
83
|
Event.new(configuration: configuration, integration_meta: integration_meta).tap do |event|
|
65
84
|
event.add_exception_interface(exception)
|
@@ -67,25 +86,36 @@ module Sentry
|
|
67
86
|
end
|
68
87
|
end
|
69
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]
|
70
93
|
def event_from_message(message, hint = {}, backtrace: nil)
|
94
|
+
return unless @configuration.sending_allowed?
|
95
|
+
|
71
96
|
integration_meta = Sentry.integrations[hint[:integration]]
|
72
97
|
event = Event.new(configuration: configuration, integration_meta: integration_meta, message: message)
|
73
98
|
event.add_threads_interface(backtrace: backtrace || caller)
|
74
99
|
event
|
75
100
|
end
|
76
101
|
|
102
|
+
# Initializes an Event object with the given Transaction object.
|
103
|
+
# @param transaction [Transaction] the transaction to be recorded.
|
104
|
+
# @return [TransactionEvent]
|
77
105
|
def event_from_transaction(transaction)
|
78
106
|
TransactionEvent.new(configuration: configuration).tap do |event|
|
79
107
|
event.transaction = transaction.name
|
80
108
|
event.contexts.merge!(trace: transaction.get_trace_context)
|
81
109
|
event.timestamp = transaction.timestamp
|
82
110
|
event.start_timestamp = transaction.start_timestamp
|
111
|
+
event.tags = transaction.tags
|
83
112
|
|
84
113
|
finished_spans = transaction.span_recorder.spans.select { |span| span.timestamp && span != transaction }
|
85
114
|
event.spans = finished_spans.map(&:to_hash)
|
86
115
|
end
|
87
116
|
end
|
88
117
|
|
118
|
+
# @!macro send_event
|
89
119
|
def send_event(event, hint = nil)
|
90
120
|
event_type = event.is_a?(Event) ? event.type : event["type"]
|
91
121
|
|
@@ -112,6 +142,10 @@ module Sentry
|
|
112
142
|
raise
|
113
143
|
end
|
114
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]
|
115
149
|
def generate_sentry_trace(span)
|
116
150
|
return unless configuration.propagate_traces
|
117
151
|
|
data/lib/sentry/configuration.rb
CHANGED
@@ -17,10 +17,15 @@ module Sentry
|
|
17
17
|
# Directories to be recognized as part of your app. e.g. if you
|
18
18
|
# have an `engines` dir at the root of your project, you may want
|
19
19
|
# to set this to something like /(app|config|engines|lib)/
|
20
|
+
#
|
21
|
+
# @return [Regexp, nil]
|
20
22
|
attr_accessor :app_dirs_pattern
|
21
23
|
|
22
24
|
# Provide an object that responds to `call` to send events asynchronously.
|
23
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]
|
24
29
|
attr_reader :async
|
25
30
|
|
26
31
|
# to send events in a non-blocking way, sentry-ruby has its own background worker
|
@@ -30,143 +35,180 @@ module Sentry
|
|
30
35
|
#
|
31
36
|
# if you want to send events synchronously, set the value to 0
|
32
37
|
# E.g.: config.background_worker_threads = 0
|
38
|
+
# @return [Integer]
|
33
39
|
attr_accessor :background_worker_threads
|
34
40
|
|
35
41
|
# a proc/lambda that takes an array of stack traces
|
36
42
|
# it'll be used to silence (reduce) backtrace of the exception
|
37
43
|
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# Rails.backtrace_cleaner.clean(backtrace)
|
43
|
-
# end
|
44
|
-
# ```
|
44
|
+
# @example
|
45
|
+
# config.backtrace_cleanup_callback = lambda do |backtrace|
|
46
|
+
# Rails.backtrace_cleaner.clean(backtrace)
|
47
|
+
# end
|
45
48
|
#
|
49
|
+
# @return [Proc, nil]
|
46
50
|
attr_accessor :backtrace_cleanup_callback
|
47
51
|
|
48
52
|
# Optional Proc, called before adding the breadcrumb to the current scope
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
53
|
+
# @example
|
54
|
+
# config.before = lambda do |breadcrumb, hint|
|
55
|
+
# breadcrumb.message = 'a'
|
56
|
+
# breadcrumb
|
57
|
+
# end
|
58
|
+
# @return [Proc]
|
55
59
|
attr_reader :before_breadcrumb
|
56
60
|
|
57
|
-
# Optional Proc, called before sending an event to the server
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
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]
|
64
73
|
attr_reader :before_send
|
65
74
|
|
66
75
|
# An array of breadcrumbs loggers to be used. Available options are:
|
67
76
|
# - :sentry_logger
|
77
|
+
# - :http_logger
|
78
|
+
# - :redis_logger
|
79
|
+
#
|
80
|
+
# And if you also use sentry-rails:
|
68
81
|
# - :active_support_logger
|
82
|
+
# - :monotonic_active_support_logger
|
83
|
+
#
|
84
|
+
# @return [Array<Symbol>]
|
69
85
|
attr_reader :breadcrumbs_logger
|
70
86
|
|
71
87
|
# Whether to capture local variables from the raised exception's frame. Default is false.
|
88
|
+
# @return [Boolean]
|
72
89
|
attr_accessor :capture_exception_frame_locals
|
73
90
|
|
74
91
|
# Max number of breadcrumbs a breadcrumb buffer can hold
|
92
|
+
# @return [Integer]
|
75
93
|
attr_accessor :max_breadcrumbs
|
76
94
|
|
77
95
|
# Number of lines of code context to capture, or nil for none
|
96
|
+
# @return [Integer, nil]
|
78
97
|
attr_accessor :context_lines
|
79
98
|
|
80
99
|
# RACK_ENV by default.
|
100
|
+
# @return [String]
|
81
101
|
attr_reader :environment
|
82
102
|
|
83
103
|
# Whether the SDK should run in the debugging mode. Default is false.
|
84
104
|
# If set to true, SDK errors will be logged with backtrace
|
105
|
+
# @return [Boolean]
|
85
106
|
attr_accessor :debug
|
86
107
|
|
87
108
|
# the dsn value, whether it's set via `config.dsn=` or `ENV["SENTRY_DSN"]`
|
109
|
+
# @return [String]
|
88
110
|
attr_reader :dsn
|
89
111
|
|
90
112
|
# Whitelist of enabled_environments that will send notifications to Sentry. Array of Strings.
|
113
|
+
# @return [Array<String>]
|
91
114
|
attr_accessor :enabled_environments
|
92
115
|
|
93
116
|
# Logger 'progname's to exclude from breadcrumbs
|
117
|
+
# @return [Array<String>]
|
94
118
|
attr_accessor :exclude_loggers
|
95
119
|
|
96
120
|
# Array of exception classes that should never be sent. See IGNORE_DEFAULT.
|
97
121
|
# You should probably append to this rather than overwrite it.
|
122
|
+
# @return [Array<String>]
|
98
123
|
attr_accessor :excluded_exceptions
|
99
124
|
|
100
125
|
# Boolean to check nested exceptions when deciding if to exclude. Defaults to true
|
126
|
+
# @return [Boolean]
|
101
127
|
attr_accessor :inspect_exception_causes_for_exclusion
|
102
128
|
alias inspect_exception_causes_for_exclusion? inspect_exception_causes_for_exclusion
|
103
129
|
|
104
130
|
# You may provide your own LineCache for matching paths with source files.
|
105
|
-
# This may be useful if you need to get source code from places other than
|
106
|
-
#
|
131
|
+
# This may be useful if you need to get source code from places other than the disk.
|
132
|
+
# @see LineCache
|
133
|
+
# @return [LineCache]
|
107
134
|
attr_accessor :linecache
|
108
135
|
|
109
136
|
# Logger used by Sentry. In Rails, this is the Rails logger, otherwise
|
110
137
|
# Sentry provides its own Sentry::Logger.
|
138
|
+
# @return [Logger]
|
111
139
|
attr_accessor :logger
|
112
140
|
|
113
141
|
# Project directory root for in_app detection. Could be Rails root, etc.
|
114
142
|
# Set automatically for Rails.
|
143
|
+
# @return [String]
|
115
144
|
attr_accessor :project_root
|
116
145
|
|
117
146
|
# Insert sentry-trace to outgoing requests' headers
|
147
|
+
# @return [Boolean]
|
118
148
|
attr_accessor :propagate_traces
|
119
149
|
|
120
150
|
# Array of rack env parameters to be included in the event sent to sentry.
|
151
|
+
# @return [Array<String>]
|
121
152
|
attr_accessor :rack_env_whitelist
|
122
153
|
|
123
154
|
# Release tag to be passed with every event sent to Sentry.
|
124
155
|
# We automatically try to set this to a git SHA or Capistrano release.
|
156
|
+
# @return [String]
|
125
157
|
attr_accessor :release
|
126
158
|
|
127
159
|
# The sampling factor to apply to events. A value of 0.0 will not send
|
128
160
|
# any events, and a value of 1.0 will send 100% of events.
|
161
|
+
# @return [Float]
|
129
162
|
attr_accessor :sample_rate
|
130
163
|
|
131
164
|
# Include module versions in reports - boolean.
|
165
|
+
# @return [Boolean]
|
132
166
|
attr_accessor :send_modules
|
133
167
|
|
134
168
|
# When send_default_pii's value is false (default), sensitive information like
|
135
169
|
# - user ip
|
136
170
|
# - user cookie
|
137
171
|
# - request body
|
172
|
+
# - query string
|
138
173
|
# will not be sent to Sentry.
|
174
|
+
# @return [Boolean]
|
139
175
|
attr_accessor :send_default_pii
|
140
176
|
|
141
177
|
# Allow to skip Sentry emails within rake tasks
|
178
|
+
# @return [Boolean]
|
142
179
|
attr_accessor :skip_rake_integration
|
143
180
|
|
144
181
|
# IP ranges for trusted proxies that will be skipped when calculating IP address.
|
145
182
|
attr_accessor :trusted_proxies
|
146
183
|
|
184
|
+
# @return [String]
|
147
185
|
attr_accessor :server_name
|
148
186
|
|
149
187
|
# Return a Transport::Configuration object for transport-related configurations.
|
188
|
+
# @return [Transport]
|
150
189
|
attr_reader :transport
|
151
190
|
|
152
191
|
# Take a float between 0.0 and 1.0 as the sample rate for tracing events (transactions).
|
192
|
+
# @return [Float]
|
153
193
|
attr_accessor :traces_sample_rate
|
154
194
|
|
155
195
|
# Take a Proc that controls the sample rate for every tracing event, e.g.
|
156
|
-
#
|
157
|
-
# lambda do |tracing_context|
|
158
|
-
#
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
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]
|
163
203
|
attr_accessor :traces_sampler
|
164
204
|
|
165
205
|
# Send diagnostic client reports about dropped events, true by default
|
166
206
|
# tries to attach to an existing envelope max once every 30s
|
207
|
+
# @return [Boolean]
|
167
208
|
attr_accessor :send_client_reports
|
168
209
|
|
169
210
|
# these are not config options
|
211
|
+
# @!visibility private
|
170
212
|
attr_reader :errors, :gem_specs
|
171
213
|
|
172
214
|
# Most of these errors generate 4XX responses. In general, Sentry clients
|
@@ -287,11 +329,6 @@ module Sentry
|
|
287
329
|
Random.rand < sample_rate
|
288
330
|
end
|
289
331
|
|
290
|
-
def error_messages
|
291
|
-
@errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first
|
292
|
-
@errors.join(", ")
|
293
|
-
end
|
294
|
-
|
295
332
|
def exception_class_allowed?(exc)
|
296
333
|
if exc.is_a?(Sentry::Error)
|
297
334
|
# Try to prevent error reporting loops
|
@@ -313,6 +350,17 @@ module Sentry
|
|
313
350
|
!!((@traces_sample_rate && @traces_sample_rate >= 0.0 && @traces_sample_rate <= 1.0) || @traces_sampler) && sending_allowed?
|
314
351
|
end
|
315
352
|
|
353
|
+
# @return [String, nil]
|
354
|
+
def csp_report_uri
|
355
|
+
if dsn && dsn.valid?
|
356
|
+
uri = dsn.csp_report_uri
|
357
|
+
uri += "&sentry_release=#{CGI.escape(release)}" if release && !release.empty?
|
358
|
+
uri += "&sentry_environment=#{CGI.escape(environment)}" if environment && !environment.empty?
|
359
|
+
uri
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
# @api private
|
316
364
|
def stacktrace_builder
|
317
365
|
@stacktrace_builder ||= StacktraceBuilder.new(
|
318
366
|
project_root: @project_root.to_s,
|
@@ -323,6 +371,7 @@ module Sentry
|
|
323
371
|
)
|
324
372
|
end
|
325
373
|
|
374
|
+
# @api private
|
326
375
|
def detect_release
|
327
376
|
return unless sending_allowed?
|
328
377
|
|
@@ -335,13 +384,10 @@ module Sentry
|
|
335
384
|
log_error("Error detecting release", e, debug: debug)
|
336
385
|
end
|
337
386
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
uri += "&sentry_environment=#{CGI.escape(environment)}" if environment && !environment.empty?
|
343
|
-
uri
|
344
|
-
end
|
387
|
+
# @api private
|
388
|
+
def error_messages
|
389
|
+
@errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first
|
390
|
+
@errors.join(", ")
|
345
391
|
end
|
346
392
|
|
347
393
|
private
|