sentry-ruby 5.28.1 → 6.0.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/Gemfile +1 -1
- data/lib/sentry/background_worker.rb +1 -4
- data/lib/sentry/breadcrumb.rb +1 -1
- data/lib/sentry/breadcrumb_buffer.rb +2 -2
- data/lib/sentry/check_in_event.rb +2 -2
- data/lib/sentry/client.rb +26 -87
- data/lib/sentry/configuration.rb +74 -75
- data/lib/sentry/cron/monitor_check_ins.rb +3 -3
- data/lib/sentry/cron/monitor_config.rb +2 -2
- data/lib/sentry/cron/monitor_schedule.rb +2 -2
- data/lib/sentry/envelope/item.rb +1 -2
- data/lib/sentry/error_event.rb +3 -3
- data/lib/sentry/event.rb +4 -10
- data/lib/sentry/hub.rb +3 -4
- data/lib/sentry/interface.rb +1 -1
- data/lib/sentry/interfaces/exception.rb +2 -2
- data/lib/sentry/interfaces/request.rb +2 -0
- data/lib/sentry/interfaces/single_exception.rb +3 -3
- data/lib/sentry/interfaces/stacktrace.rb +3 -3
- data/lib/sentry/interfaces/stacktrace_builder.rb +0 -8
- data/lib/sentry/interfaces/threads.rb +2 -2
- data/lib/sentry/log_event.rb +1 -1
- data/lib/sentry/profiler.rb +4 -5
- data/lib/sentry/rspec.rb +1 -1
- data/lib/sentry/span.rb +2 -17
- data/lib/sentry/test_helper.rb +1 -0
- data/lib/sentry/transaction.rb +52 -103
- data/lib/sentry/transaction_event.rb +4 -9
- data/lib/sentry/transport.rb +2 -5
- data/lib/sentry/utils/logging_helper.rb +8 -6
- data/lib/sentry/vernier/profiler.rb +4 -3
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +2 -30
- data/sentry-ruby-core.gemspec +1 -1
- data/sentry-ruby.gemspec +1 -1
- metadata +7 -17
- data/lib/sentry/metrics/aggregator.rb +0 -248
- data/lib/sentry/metrics/configuration.rb +0 -57
- data/lib/sentry/metrics/counter_metric.rb +0 -25
- data/lib/sentry/metrics/distribution_metric.rb +0 -25
- data/lib/sentry/metrics/gauge_metric.rb +0 -35
- data/lib/sentry/metrics/local_aggregator.rb +0 -53
- data/lib/sentry/metrics/metric.rb +0 -19
- data/lib/sentry/metrics/set_metric.rb +0 -28
- data/lib/sentry/metrics/timing.rb +0 -51
- data/lib/sentry/metrics.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a6e7b2113d1332eaaf78dc5b8a4989b0a1395796a43fb1f7225cc8115f0ac5
|
4
|
+
data.tar.gz: 64aaefd79ec8d357586ec99cea6f21d749f21a5fc80226b9a554f5f6a3f25870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4db52a4de3aada20c59eec1f949d8577fa2acf6a1772ca450fca97ddbbbf6676654ee60a585c82af020d54bd24b5ccc593dcad86e54e44bfcaafc6d385e4fac5
|
7
|
+
data.tar.gz: d3489ef60748f864cb4ad59f5f823ad5ca6a3ff6aee54e6c859a140af4947bffca91c37ae1dca5ee9d46d18b2b4e33f1df69085d328168eed96842443fd00719
|
data/Gemfile
CHANGED
@@ -20,7 +20,7 @@ gem "timecop"
|
|
20
20
|
gem "stackprof" unless RUBY_PLATFORM == "java"
|
21
21
|
gem "vernier", platforms: :ruby if RUBY_VERSION >= "3.2.1"
|
22
22
|
|
23
|
-
gem "graphql", ">= 2.2.6"
|
23
|
+
gem "graphql", ">= 2.2.6"
|
24
24
|
|
25
25
|
gem "benchmark-ips"
|
26
26
|
gem "benchmark_driver"
|
@@ -23,10 +23,7 @@ module Sentry
|
|
23
23
|
@shutdown_callback = nil
|
24
24
|
|
25
25
|
@executor =
|
26
|
-
if
|
27
|
-
log_debug("config.async is set, BackgroundWorker is disabled")
|
28
|
-
Concurrent::ImmediateExecutor.new
|
29
|
-
elsif @number_of_threads == 0
|
26
|
+
if @number_of_threads == 0
|
30
27
|
log_debug("config.background_worker_threads is set to 0, all events will be sent synchronously")
|
31
28
|
Concurrent::ImmediateExecutor.new
|
32
29
|
else
|
data/lib/sentry/breadcrumb.rb
CHANGED
@@ -48,13 +48,13 @@ module Sentry
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# @return [Hash]
|
51
|
-
def
|
51
|
+
def to_h
|
52
52
|
data = super
|
53
53
|
data[:check_in_id] = check_in_id
|
54
54
|
data[:monitor_slug] = monitor_slug
|
55
55
|
data[:status] = status
|
56
56
|
data[:duration] = duration if duration
|
57
|
-
data[:monitor_config] = monitor_config.
|
57
|
+
data[:monitor_config] = monitor_config.to_h if monitor_config
|
58
58
|
data
|
59
59
|
end
|
60
60
|
end
|
data/lib/sentry/client.rb
CHANGED
@@ -60,8 +60,7 @@ module Sentry
|
|
60
60
|
return
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
data_category = Envelope::Item.data_category(event_type)
|
63
|
+
data_category = Envelope::Item.data_category(event.type)
|
65
64
|
|
66
65
|
is_transaction = event.is_a?(TransactionEvent)
|
67
66
|
spans_before = is_transaction ? event.spans.size : 0
|
@@ -78,9 +77,7 @@ module Sentry
|
|
78
77
|
transport.record_lost_event(:event_processor, "span", num: spans_delta) if spans_delta > 0
|
79
78
|
end
|
80
79
|
|
81
|
-
if
|
82
|
-
dispatch_async_event(async_block, event, hint)
|
83
|
-
elsif configuration.background_worker_threads != 0 && hint.fetch(:background, true)
|
80
|
+
if configuration.background_worker_threads != 0 && hint.fetch(:background, true)
|
84
81
|
unless dispatch_background_event(event, hint)
|
85
82
|
transport.record_lost_event(:queue_overflow, data_category)
|
86
83
|
transport.record_lost_event(:queue_overflow, "span", num: spans_before + 1) if is_transaction
|
@@ -210,22 +207,13 @@ module Sentry
|
|
210
207
|
|
211
208
|
# @!macro send_event
|
212
209
|
def send_event(event, hint = nil)
|
213
|
-
|
214
|
-
data_category = Envelope::Item.data_category(event_type)
|
210
|
+
data_category = Envelope::Item.data_category(event.type)
|
215
211
|
spans_before = event.is_a?(TransactionEvent) ? event.spans.size : 0
|
216
212
|
|
217
|
-
if
|
213
|
+
if event.is_a?(ErrorEvent) && configuration.before_send
|
218
214
|
event = configuration.before_send.call(event, hint)
|
219
215
|
|
220
|
-
|
221
|
-
when ErrorEvent, CheckInEvent
|
222
|
-
# do nothing
|
223
|
-
when Hash
|
224
|
-
log_debug(<<~MSG)
|
225
|
-
Returning a Hash from before_send is deprecated and will be removed in the next major version.
|
226
|
-
Please return a Sentry::ErrorEvent object instead.
|
227
|
-
MSG
|
228
|
-
else
|
216
|
+
if !event.is_a?(ErrorEvent)
|
229
217
|
# Avoid serializing the event object in this case because we aren't sure what it is and what it contains
|
230
218
|
log_debug(<<~MSG)
|
231
219
|
Discarded event because before_send didn't return a Sentry::ErrorEvent object but an instance of #{event.class}
|
@@ -235,21 +223,10 @@ module Sentry
|
|
235
223
|
end
|
236
224
|
end
|
237
225
|
|
238
|
-
if
|
226
|
+
if event.is_a?(TransactionEvent) && configuration.before_send_transaction
|
239
227
|
event = configuration.before_send_transaction.call(event, hint)
|
240
228
|
|
241
|
-
if event.is_a?(TransactionEvent)
|
242
|
-
spans_after = event.is_a?(TransactionEvent) ? event.spans.size : 0
|
243
|
-
spans_delta = spans_before - spans_after
|
244
|
-
transport.record_lost_event(:before_send, "span", num: spans_delta) if spans_delta > 0
|
245
|
-
|
246
|
-
if event.is_a?(Hash)
|
247
|
-
log_debug(<<~MSG)
|
248
|
-
Returning a Hash from before_send_transaction is deprecated and will be removed in the next major version.
|
249
|
-
Please return a Sentry::TransactionEvent object instead.
|
250
|
-
MSG
|
251
|
-
end
|
252
|
-
else
|
229
|
+
if !event.is_a?(TransactionEvent)
|
253
230
|
# Avoid serializing the event object in this case because we aren't sure what it is and what it contains
|
254
231
|
log_debug(<<~MSG)
|
255
232
|
Discarded event because before_send_transaction didn't return a Sentry::TransactionEvent object but an instance of #{event.class}
|
@@ -258,6 +235,23 @@ module Sentry
|
|
258
235
|
transport.record_lost_event(:before_send, "span", num: spans_before + 1)
|
259
236
|
return
|
260
237
|
end
|
238
|
+
|
239
|
+
spans_after = event.is_a?(TransactionEvent) ? event.spans.size : 0
|
240
|
+
spans_delta = spans_before - spans_after
|
241
|
+
transport.record_lost_event(:before_send, "span", num: spans_delta) if spans_delta > 0
|
242
|
+
end
|
243
|
+
|
244
|
+
if event.is_a?(CheckInEvent) && configuration.before_send_check_in
|
245
|
+
event = configuration.before_send_check_in.call(event, hint)
|
246
|
+
|
247
|
+
if !event.is_a?(CheckInEvent)
|
248
|
+
# Avoid serializing the event object in this case because we aren't sure what it is and what it contains
|
249
|
+
log_debug(<<~MSG)
|
250
|
+
Discarded event because before_send_check_in didn't return a Sentry::CheckInEvent object but an instance of #{event.class}
|
251
|
+
MSG
|
252
|
+
transport.record_lost_event(:before_send, data_category)
|
253
|
+
return
|
254
|
+
end
|
261
255
|
end
|
262
256
|
|
263
257
|
transport.send_event(event) if configuration.sending_to_dsn_allowed?
|
@@ -291,7 +285,7 @@ module Sentry
|
|
291
285
|
processed_log_event = configuration.before_send_log.call(log_event)
|
292
286
|
|
293
287
|
if processed_log_event
|
294
|
-
envelope_items << processed_log_event.
|
288
|
+
envelope_items << processed_log_event.to_h
|
295
289
|
else
|
296
290
|
discarded_count += 1
|
297
291
|
end
|
@@ -299,7 +293,7 @@ module Sentry
|
|
299
293
|
|
300
294
|
envelope_items
|
301
295
|
else
|
302
|
-
envelope_items = log_events.map(&:
|
296
|
+
envelope_items = log_events.map(&:to_h)
|
303
297
|
end
|
304
298
|
|
305
299
|
envelope.add_item(
|
@@ -334,38 +328,6 @@ module Sentry
|
|
334
328
|
raise
|
335
329
|
end
|
336
330
|
|
337
|
-
# @deprecated use Sentry.get_traceparent instead.
|
338
|
-
#
|
339
|
-
# Generates a Sentry trace for distribted tracing from the given Span.
|
340
|
-
# Returns `nil` if `config.propagate_traces` is `false`.
|
341
|
-
# @param span [Span] the span to generate trace from.
|
342
|
-
# @return [String, nil]
|
343
|
-
def generate_sentry_trace(span)
|
344
|
-
return unless configuration.propagate_traces
|
345
|
-
|
346
|
-
trace = span.to_sentry_trace
|
347
|
-
log_debug("[Tracing] Adding #{SENTRY_TRACE_HEADER_NAME} header to outgoing request: #{trace}")
|
348
|
-
trace
|
349
|
-
end
|
350
|
-
|
351
|
-
# @deprecated Use Sentry.get_baggage instead.
|
352
|
-
#
|
353
|
-
# Generates a W3C Baggage header for distributed tracing from the given Span.
|
354
|
-
# Returns `nil` if `config.propagate_traces` is `false`.
|
355
|
-
# @param span [Span] the span to generate trace from.
|
356
|
-
# @return [String, nil]
|
357
|
-
def generate_baggage(span)
|
358
|
-
return unless configuration.propagate_traces
|
359
|
-
|
360
|
-
baggage = span.to_baggage
|
361
|
-
|
362
|
-
if baggage && !baggage.empty?
|
363
|
-
log_debug("[Tracing] Adding #{BAGGAGE_HEADER_NAME} header to outgoing request: #{baggage}")
|
364
|
-
end
|
365
|
-
|
366
|
-
baggage
|
367
|
-
end
|
368
|
-
|
369
331
|
private
|
370
332
|
|
371
333
|
def dispatch_background_event(event, hint)
|
@@ -373,28 +335,5 @@ module Sentry
|
|
373
335
|
send_event(event, hint)
|
374
336
|
end
|
375
337
|
end
|
376
|
-
|
377
|
-
def dispatch_async_event(async_block, event, hint)
|
378
|
-
# We have to convert to a JSON-like hash, because background job
|
379
|
-
# processors (esp ActiveJob) may not like weird types in the event hash
|
380
|
-
|
381
|
-
event_hash =
|
382
|
-
begin
|
383
|
-
event.to_json_compatible
|
384
|
-
rescue => e
|
385
|
-
log_error("Converting #{event.type} (#{event.event_id}) to JSON compatible hash failed", e, debug: configuration.debug)
|
386
|
-
return
|
387
|
-
end
|
388
|
-
|
389
|
-
if async_block.arity == 2
|
390
|
-
hint = JSON.parse(JSON.generate(hint))
|
391
|
-
async_block.call(event_hash, hint)
|
392
|
-
else
|
393
|
-
async_block.call(event_hash)
|
394
|
-
end
|
395
|
-
rescue => e
|
396
|
-
log_error("Async #{event_hash["type"]} sending failed", e, debug: configuration.debug)
|
397
|
-
send_event(event, hint)
|
398
|
-
end
|
399
338
|
end
|
400
339
|
end
|
data/lib/sentry/configuration.rb
CHANGED
@@ -9,7 +9,6 @@ require "sentry/dsn"
|
|
9
9
|
require "sentry/release_detector"
|
10
10
|
require "sentry/transport/configuration"
|
11
11
|
require "sentry/cron/configuration"
|
12
|
-
require "sentry/metrics/configuration"
|
13
12
|
require "sentry/linecache"
|
14
13
|
require "sentry/interfaces/stacktrace_builder"
|
15
14
|
require "sentry/logger"
|
@@ -31,13 +30,6 @@ module Sentry
|
|
31
30
|
# @return [Regexp, nil]
|
32
31
|
attr_accessor :app_dirs_pattern
|
33
32
|
|
34
|
-
# Provide an object that responds to `call` to send events asynchronously.
|
35
|
-
# E.g.: lambda { |event| Thread.new { Sentry.send_event(event) } }
|
36
|
-
#
|
37
|
-
# @deprecated It will be removed in the next major release. Please read https://github.com/getsentry/sentry-ruby/issues/1522 for more information
|
38
|
-
# @return [Proc, nil]
|
39
|
-
attr_reader :async
|
40
|
-
|
41
33
|
# to send events in a non-blocking way, sentry-ruby has its own background worker
|
42
34
|
# by default, the worker holds a thread pool that has [the number of processors] threads
|
43
35
|
# but you can configure it with this configuration option
|
@@ -75,11 +67,10 @@ module Sentry
|
|
75
67
|
# @return [Proc]
|
76
68
|
attr_reader :before_breadcrumb
|
77
69
|
|
78
|
-
# Optional Proc, called before sending an event to the server
|
70
|
+
# Optional Proc, called before sending an error event to the server
|
79
71
|
# @example
|
80
72
|
# config.before_send = lambda do |event, hint|
|
81
73
|
# # skip ZeroDivisionError exceptions
|
82
|
-
# # note: hint[:exception] would be a String if you use async callback
|
83
74
|
# if hint[:exception].is_a?(ZeroDivisionError)
|
84
75
|
# nil
|
85
76
|
# else
|
@@ -89,7 +80,7 @@ module Sentry
|
|
89
80
|
# @return [Proc]
|
90
81
|
attr_reader :before_send
|
91
82
|
|
92
|
-
# Optional Proc, called before sending
|
83
|
+
# Optional Proc, called before sending a transaction event to the server
|
93
84
|
# @example
|
94
85
|
# config.before_send_transaction = lambda do |event, hint|
|
95
86
|
# # skip unimportant transactions or strip sensitive data
|
@@ -102,6 +93,18 @@ module Sentry
|
|
102
93
|
# @return [Proc]
|
103
94
|
attr_reader :before_send_transaction
|
104
95
|
|
96
|
+
# Optional Proc, called before sending a check-in event to the server
|
97
|
+
# @example
|
98
|
+
# config.before_send_check_in = lambda do |event, hint|
|
99
|
+
# if event.monitor_slug == "unimportant_job"
|
100
|
+
# nil
|
101
|
+
# else
|
102
|
+
# event
|
103
|
+
# end
|
104
|
+
# end
|
105
|
+
# @return [Proc]
|
106
|
+
attr_reader :before_send_check_in
|
107
|
+
|
105
108
|
# Optional Proc, called before sending an event to the server
|
106
109
|
# @example
|
107
110
|
# config.before_send_log = lambda do |log|
|
@@ -118,7 +121,6 @@ module Sentry
|
|
118
121
|
#
|
119
122
|
# And if you also use sentry-rails:
|
120
123
|
# - :active_support_logger
|
121
|
-
# - :monotonic_active_support_logger
|
122
124
|
#
|
123
125
|
# @return [Array<Symbol>]
|
124
126
|
attr_reader :breadcrumbs_logger
|
@@ -145,7 +147,7 @@ module Sentry
|
|
145
147
|
attr_reader :dsn
|
146
148
|
|
147
149
|
# Whitelist of enabled_environments that will send notifications to Sentry. Array of Strings.
|
148
|
-
# @return [Array<String
|
150
|
+
# @return [Array<String>, nil]
|
149
151
|
attr_accessor :enabled_environments
|
150
152
|
|
151
153
|
# Logger 'progname's to exclude from breadcrumbs
|
@@ -174,18 +176,6 @@ module Sentry
|
|
174
176
|
# @return [Boolean, String]
|
175
177
|
attr_accessor :spotlight
|
176
178
|
|
177
|
-
# @deprecated Use {#include_local_variables} instead.
|
178
|
-
alias_method :capture_exception_frame_locals, :include_local_variables
|
179
|
-
|
180
|
-
# @deprecated Use {#include_local_variables=} instead.
|
181
|
-
def capture_exception_frame_locals=(value)
|
182
|
-
log_warn <<~MSG
|
183
|
-
`capture_exception_frame_locals` is now deprecated in favor of `include_local_variables`.
|
184
|
-
MSG
|
185
|
-
|
186
|
-
self.include_local_variables = value
|
187
|
-
end
|
188
|
-
|
189
179
|
# You may provide your own LineCache for matching paths with source files.
|
190
180
|
# This may be useful if you need to get source code from places other than the disk.
|
191
181
|
# @see LineCache
|
@@ -202,18 +192,6 @@ module Sentry
|
|
202
192
|
# @return [String, nil]
|
203
193
|
attr_accessor :sdk_debug_transport_log_file
|
204
194
|
|
205
|
-
# @deprecated Use {#sdk_logger=} instead.
|
206
|
-
def logger=(logger)
|
207
|
-
warn "[sentry] `config.logger=` is deprecated. Please use `config.sdk_logger=` instead."
|
208
|
-
self.sdk_logger = logger
|
209
|
-
end
|
210
|
-
|
211
|
-
# @deprecated Use {#sdk_logger} instead.
|
212
|
-
def logger
|
213
|
-
warn "[sentry] `config.logger` is deprecated. Please use `config.sdk_logger` instead."
|
214
|
-
self.sdk_logger
|
215
|
-
end
|
216
|
-
|
217
195
|
# Project directory root for in_app detection. Could be Rails root, etc.
|
218
196
|
# Set automatically for Rails.
|
219
197
|
# @return [String]
|
@@ -273,10 +251,6 @@ module Sentry
|
|
273
251
|
# @return [Cron::Configuration]
|
274
252
|
attr_reader :cron
|
275
253
|
|
276
|
-
# Metrics related configuration.
|
277
|
-
# @return [Metrics::Configuration]
|
278
|
-
attr_reader :metrics
|
279
|
-
|
280
254
|
# Take a float between 0.0 and 1.0 as the sample rate for tracing events (transactions).
|
281
255
|
# @return [Float, nil]
|
282
256
|
attr_reader :traces_sample_rate
|
@@ -299,12 +273,6 @@ module Sentry
|
|
299
273
|
# @return [StructuredLoggingConfiguration]
|
300
274
|
attr_reader :structured_logging
|
301
275
|
|
302
|
-
# Easier way to use performance tracing
|
303
|
-
# If set to true, will set traces_sample_rate to 1.0
|
304
|
-
# @deprecated It will be removed in the next major release.
|
305
|
-
# @return [Boolean, nil]
|
306
|
-
attr_reader :enable_tracing
|
307
|
-
|
308
276
|
# Send diagnostic client reports about dropped events, true by default
|
309
277
|
# tries to attach to an existing envelope max once every 30s
|
310
278
|
# @return [Boolean]
|
@@ -325,6 +293,18 @@ module Sentry
|
|
325
293
|
# @return [Array<String, Regexp>]
|
326
294
|
attr_accessor :trace_propagation_targets
|
327
295
|
|
296
|
+
# Collection of HTTP status codes or ranges of codes to ignore when tracing incoming requests.
|
297
|
+
# If a transaction's http.response.status_code matches one of these values,
|
298
|
+
# the transaction will be dropped and marked as not sampled.
|
299
|
+
# Defaults to TRACE_IGNORE_STATUS_CODES_DEFAULT.
|
300
|
+
#
|
301
|
+
# @example
|
302
|
+
# # ignore 404 and 502 <= status_code <= 511
|
303
|
+
# config.trace_ignore_status_codes = [404, (502..511)]
|
304
|
+
#
|
305
|
+
# @return [Array<Integer>, Array<Range>]
|
306
|
+
attr_reader :trace_ignore_status_codes
|
307
|
+
|
328
308
|
# The instrumenter to use, :sentry or :otel
|
329
309
|
# @return [Symbol]
|
330
310
|
attr_reader :instrumenter
|
@@ -339,6 +319,15 @@ module Sentry
|
|
339
319
|
# @return [Float, nil]
|
340
320
|
attr_reader :profiles_sample_rate
|
341
321
|
|
322
|
+
# Interval in microseconds at which to take samples.
|
323
|
+
# The default is 1e6 / 101, or 101Hz.
|
324
|
+
# Note that the 101 is intentional to avoid lockstep sampling.
|
325
|
+
#
|
326
|
+
# @example
|
327
|
+
# config.profiles_sample_interval = 1e5 / 101
|
328
|
+
# @return [Float]
|
329
|
+
attr_accessor :profiles_sample_interval
|
330
|
+
|
342
331
|
# Array of patches to apply.
|
343
332
|
# Default is {DEFAULT_PATCHES}
|
344
333
|
# @return [Array<Symbol>]
|
@@ -376,6 +365,8 @@ module Sentry
|
|
376
365
|
SERVER_PORT
|
377
366
|
].freeze
|
378
367
|
|
368
|
+
TRACE_IGNORE_STATUS_CODES_DEFAULT = [(301..303), (305..399), (401..404)]
|
369
|
+
|
379
370
|
HEROKU_DYNO_METADATA_MESSAGE = "You are running on Heroku but haven't enabled Dyno Metadata. For Sentry's "\
|
380
371
|
"release detection to work correctly, please run `heroku labs:enable runtime-dyno-metadata`"
|
381
372
|
|
@@ -391,6 +382,9 @@ module Sentry
|
|
391
382
|
|
392
383
|
APP_DIRS_PATTERN = /(bin|exe|app|config|lib|test|spec)/
|
393
384
|
|
385
|
+
# 101 Hz in microseconds
|
386
|
+
DEFAULT_PROFILES_SAMPLE_INTERVAL = 1e6 / 101
|
387
|
+
|
394
388
|
class << self
|
395
389
|
# Post initialization callbacks are called at the end of initialization process
|
396
390
|
# allowing extending the configuration of sentry-ruby by multiple extensions
|
@@ -473,7 +467,7 @@ module Sentry
|
|
473
467
|
self.context_lines = 3
|
474
468
|
self.include_local_variables = false
|
475
469
|
self.environment = environment_from_env
|
476
|
-
self.enabled_environments =
|
470
|
+
self.enabled_environments = nil
|
477
471
|
self.exclude_loggers = []
|
478
472
|
self.excluded_exceptions = IGNORE_DEFAULT + PUMA_IGNORE_DEFAULT
|
479
473
|
self.inspect_exception_causes_for_exclusion = true
|
@@ -498,21 +492,22 @@ module Sentry
|
|
498
492
|
self.server_name = server_name_from_env
|
499
493
|
self.instrumenter = :sentry
|
500
494
|
self.trace_propagation_targets = [PROPAGATION_TARGETS_MATCH_ALL]
|
495
|
+
self.trace_ignore_status_codes = TRACE_IGNORE_STATUS_CODES_DEFAULT
|
501
496
|
self.enabled_patches = DEFAULT_PATCHES.dup
|
502
497
|
|
503
498
|
self.before_send = nil
|
504
499
|
self.before_send_transaction = nil
|
500
|
+
self.before_send_check_in = nil
|
505
501
|
self.before_send_log = nil
|
506
502
|
self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT
|
507
503
|
self.traces_sampler = nil
|
508
|
-
self.enable_tracing = nil
|
509
504
|
self.enable_logs = false
|
510
505
|
|
511
506
|
self.profiler_class = Sentry::Profiler
|
507
|
+
self.profiles_sample_interval = DEFAULT_PROFILES_SAMPLE_INTERVAL
|
512
508
|
|
513
509
|
@transport = Transport::Configuration.new
|
514
510
|
@cron = Cron::Configuration.new
|
515
|
-
@metrics = Metrics::Configuration.new(self.sdk_logger)
|
516
511
|
@structured_logging = StructuredLoggingConfiguration.new
|
517
512
|
@gem_specs = Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map)
|
518
513
|
|
@@ -555,22 +550,6 @@ module Sentry
|
|
555
550
|
@release = value
|
556
551
|
end
|
557
552
|
|
558
|
-
def async=(value)
|
559
|
-
check_callable!("async", value)
|
560
|
-
|
561
|
-
log_warn <<~MSG
|
562
|
-
|
563
|
-
sentry-ruby now sends events asynchronously by default with its background worker (supported since 4.1.0).
|
564
|
-
The `config.async` callback has become redundant while continuing to cause issues.
|
565
|
-
(The problems of `async` are detailed in https://github.com/getsentry/sentry-ruby/issues/1522)
|
566
|
-
|
567
|
-
Therefore, we encourage you to remove it and let the background worker take care of async job sending.
|
568
|
-
It's deprecation is planned in the next major release (6.0), which is scheduled around the 3rd quarter of 2022.
|
569
|
-
MSG
|
570
|
-
|
571
|
-
@async = value
|
572
|
-
end
|
573
|
-
|
574
553
|
def breadcrumbs_logger=(logger)
|
575
554
|
loggers =
|
576
555
|
if logger.is_a?(Array)
|
@@ -596,6 +575,12 @@ module Sentry
|
|
596
575
|
@before_send_transaction = value
|
597
576
|
end
|
598
577
|
|
578
|
+
def before_send_check_in=(value)
|
579
|
+
check_callable!("before_send_check_in", value)
|
580
|
+
|
581
|
+
@before_send_check_in = value
|
582
|
+
end
|
583
|
+
|
599
584
|
def before_breadcrumb=(value)
|
600
585
|
check_callable!("before_breadcrumb", value)
|
601
586
|
|
@@ -610,15 +595,12 @@ module Sentry
|
|
610
595
|
@instrumenter = INSTRUMENTERS.include?(instrumenter) ? instrumenter : :sentry
|
611
596
|
end
|
612
597
|
|
613
|
-
def
|
614
|
-
unless
|
615
|
-
|
616
|
-
`enable_tracing` is now deprecated in favor of `traces_sample_rate = 1.0`.
|
617
|
-
MSG
|
598
|
+
def trace_ignore_status_codes=(codes)
|
599
|
+
unless codes.is_a?(Array) && codes.all? { |code| valid_status_code_entry?(code) }
|
600
|
+
raise ArgumentError, "trace_ignore_status_codes must be an Array of integers or ranges between (100-599) where begin <= end"
|
618
601
|
end
|
619
602
|
|
620
|
-
@
|
621
|
-
@traces_sample_rate ||= 1.0 if enable_tracing
|
603
|
+
@trace_ignore_status_codes = codes
|
622
604
|
end
|
623
605
|
|
624
606
|
def traces_sample_rate=(traces_sample_rate)
|
@@ -674,7 +656,7 @@ module Sentry
|
|
674
656
|
end
|
675
657
|
|
676
658
|
def enabled_in_current_env?
|
677
|
-
enabled_environments.
|
659
|
+
enabled_environments.nil? || enabled_environments.include?(environment)
|
678
660
|
end
|
679
661
|
|
680
662
|
def valid_sample_rate?(sample_rate)
|
@@ -685,7 +667,7 @@ module Sentry
|
|
685
667
|
def tracing_enabled?
|
686
668
|
valid_sampler = !!((valid_sample_rate?(@traces_sample_rate)) || @traces_sampler)
|
687
669
|
|
688
|
-
|
670
|
+
valid_sampler && sending_allowed?
|
689
671
|
end
|
690
672
|
|
691
673
|
def profiling_enabled?
|
@@ -816,6 +798,23 @@ module Sentry
|
|
816
798
|
available_processor_count = Concurrent.available_processor_count if Concurrent.respond_to?(:available_processor_count)
|
817
799
|
available_processor_count || Concurrent.processor_count
|
818
800
|
end
|
801
|
+
|
802
|
+
def valid_http_status_code?(code)
|
803
|
+
code.is_a?(Integer) && code >= 100 && code <= 599
|
804
|
+
end
|
805
|
+
|
806
|
+
def valid_status_code_entry?(entry)
|
807
|
+
case entry
|
808
|
+
when Integer
|
809
|
+
valid_http_status_code?(entry)
|
810
|
+
when Range
|
811
|
+
valid_http_status_code?(entry.begin) &&
|
812
|
+
valid_http_status_code?(entry.end) &&
|
813
|
+
entry.begin <= entry.end
|
814
|
+
else
|
815
|
+
false
|
816
|
+
end
|
817
|
+
end
|
819
818
|
end
|
820
819
|
|
821
820
|
class StructuredLoggingConfiguration
|
@@ -14,12 +14,12 @@ module Sentry
|
|
14
14
|
:in_progress,
|
15
15
|
monitor_config: monitor_config)
|
16
16
|
|
17
|
-
start =
|
17
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
18
18
|
|
19
19
|
begin
|
20
20
|
# need to do this on ruby <= 2.6 sadly
|
21
21
|
ret = method(:perform).super_method.arity == 0 ? super() : super
|
22
|
-
duration =
|
22
|
+
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
23
23
|
|
24
24
|
Sentry.capture_check_in(slug,
|
25
25
|
:ok,
|
@@ -29,7 +29,7 @@ module Sentry
|
|
29
29
|
|
30
30
|
ret
|
31
31
|
rescue Exception
|
32
|
-
duration =
|
32
|
+
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
33
33
|
|
34
34
|
Sentry.capture_check_in(slug,
|
35
35
|
:error,
|
@@ -40,9 +40,9 @@ module Sentry
|
|
40
40
|
new(MonitorSchedule::Interval.new(num, unit), **options)
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
43
|
+
def to_h
|
44
44
|
{
|
45
|
-
schedule: schedule.
|
45
|
+
schedule: schedule.to_h,
|
46
46
|
checkin_margin: checkin_margin,
|
47
47
|
max_runtime: max_runtime,
|
48
48
|
timezone: timezone
|
@@ -12,7 +12,7 @@ module Sentry
|
|
12
12
|
@value = value
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def to_h
|
16
16
|
{ type: :crontab, value: value }
|
17
17
|
end
|
18
18
|
end
|
@@ -33,7 +33,7 @@ module Sentry
|
|
33
33
|
@unit = unit
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def to_h
|
37
37
|
{ type: :interval, value: value, unit: unit }
|
38
38
|
end
|
39
39
|
end
|
data/lib/sentry/envelope/item.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Sentry
|
4
4
|
# @api private
|
5
5
|
class Envelope::Item
|
6
|
-
STACKTRACE_FRAME_LIMIT_ON_OVERSIZED_PAYLOAD =
|
6
|
+
STACKTRACE_FRAME_LIMIT_ON_OVERSIZED_PAYLOAD = 1000
|
7
7
|
MAX_SERIALIZED_PAYLOAD_SIZE = 1024 * 1000
|
8
8
|
|
9
9
|
SIZE_LIMITS = Hash.new(MAX_SERIALIZED_PAYLOAD_SIZE).update(
|
@@ -18,7 +18,6 @@ module Sentry
|
|
18
18
|
when "session", "attachment", "transaction", "profile", "span", "log" then type
|
19
19
|
when "sessions" then "session"
|
20
20
|
when "check_in" then "monitor"
|
21
|
-
when "statsd", "metric_meta" then "metric_bucket"
|
22
21
|
when "event" then "error"
|
23
22
|
when "client_report" then "internal"
|
24
23
|
else "default"
|
data/lib/sentry/error_event.rb
CHANGED
@@ -10,10 +10,10 @@ module Sentry
|
|
10
10
|
attr_reader :threads
|
11
11
|
|
12
12
|
# @return [Hash]
|
13
|
-
def
|
13
|
+
def to_h
|
14
14
|
data = super
|
15
|
-
data[:threads] = threads.
|
16
|
-
data[:exception] = exception.
|
15
|
+
data[:threads] = threads.to_h if threads
|
16
|
+
data[:exception] = exception.to_h if exception
|
17
17
|
data
|
18
18
|
end
|
19
19
|
|