sentry-ruby 5.15.2 → 5.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sentry/background_worker.rb +5 -0
- data/lib/sentry/backpressure_monitor.rb +75 -0
- data/lib/sentry/client.rb +4 -8
- data/lib/sentry/configuration.rb +16 -3
- data/lib/sentry/cron/configuration.rb +23 -0
- data/lib/sentry/cron/monitor_check_ins.rb +27 -19
- data/lib/sentry/event.rb +0 -28
- data/lib/sentry/hub.rb +2 -2
- data/lib/sentry/rake.rb +0 -13
- data/lib/sentry/scope.rb +12 -11
- data/lib/sentry/transaction.rb +9 -2
- data/lib/sentry/transport/http_transport.rb +6 -10
- data/lib/sentry/transport.rb +19 -5
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +25 -23
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 565289974a80625ef7ecac6926cfb7292569dfafd84f12584a8214619bdd5ed5
|
4
|
+
data.tar.gz: 005b3e5c27b7188058c412d36981779eb759f7be1032429eea17a2e4a7ffcb9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0e68db7961263d6aa070feaa131fae4c2039884e565cd248795298a99f08d66e7c921df1a6f6175e68ac0ed554185b4b94769f8b0fcba12d76e6aa042fc3359
|
7
|
+
data.tar.gz: 5e10f1406d7a7809aed02cef80e1d4355e61af54ed42ffd9a1b3a54a730229abfef4f0a690980c646757b93fffa6219d6500c5700b08a6eef61b6eb682d63620
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sentry
|
4
|
+
class BackpressureMonitor
|
5
|
+
include LoggingHelper
|
6
|
+
|
7
|
+
DEFAULT_INTERVAL = 10
|
8
|
+
MAX_DOWNSAMPLE_FACTOR = 10
|
9
|
+
|
10
|
+
def initialize(configuration, client, interval: DEFAULT_INTERVAL)
|
11
|
+
@interval = interval
|
12
|
+
@client = client
|
13
|
+
@logger = configuration.logger
|
14
|
+
|
15
|
+
@thread = nil
|
16
|
+
@exited = false
|
17
|
+
|
18
|
+
@healthy = true
|
19
|
+
@downsample_factor = 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def healthy?
|
23
|
+
ensure_thread
|
24
|
+
@healthy
|
25
|
+
end
|
26
|
+
|
27
|
+
def downsample_factor
|
28
|
+
ensure_thread
|
29
|
+
@downsample_factor
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
check_health
|
34
|
+
set_downsample_factor
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_health
|
38
|
+
@healthy = !(@client.transport.any_rate_limited? || Sentry.background_worker&.full?)
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_downsample_factor
|
42
|
+
if @healthy
|
43
|
+
log_debug("[BackpressureMonitor] health check positive, reverting to normal sampling") if @downsample_factor.positive?
|
44
|
+
@downsample_factor = 0
|
45
|
+
else
|
46
|
+
@downsample_factor += 1 if @downsample_factor < MAX_DOWNSAMPLE_FACTOR
|
47
|
+
log_debug("[BackpressureMonitor] health check negative, downsampling with a factor of #{@downsample_factor}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def kill
|
52
|
+
log_debug("[BackpressureMonitor] killing monitor")
|
53
|
+
|
54
|
+
@exited = true
|
55
|
+
@thread&.kill
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def ensure_thread
|
61
|
+
return if @exited
|
62
|
+
return if @thread&.alive?
|
63
|
+
|
64
|
+
@thread = Thread.new do
|
65
|
+
loop do
|
66
|
+
sleep(@interval)
|
67
|
+
run
|
68
|
+
end
|
69
|
+
end
|
70
|
+
rescue ThreadError
|
71
|
+
log_debug("[BackpressureMonitor] Thread creation failed")
|
72
|
+
@exited = true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/sentry/client.rb
CHANGED
@@ -57,7 +57,7 @@ module Sentry
|
|
57
57
|
event = scope.apply_to_event(event, hint)
|
58
58
|
|
59
59
|
if event.nil?
|
60
|
-
|
60
|
+
log_debug("Discarded event because one of the event processors returned nil")
|
61
61
|
transport.record_lost_event(:event_processor, event_type)
|
62
62
|
return
|
63
63
|
end
|
@@ -156,7 +156,7 @@ module Sentry
|
|
156
156
|
event = configuration.before_send.call(event, hint)
|
157
157
|
|
158
158
|
if event.nil?
|
159
|
-
|
159
|
+
log_debug("Discarded event because before_send returned nil")
|
160
160
|
transport.record_lost_event(:before_send, 'event')
|
161
161
|
return
|
162
162
|
end
|
@@ -166,7 +166,7 @@ module Sentry
|
|
166
166
|
event = configuration.before_send_transaction.call(event, hint)
|
167
167
|
|
168
168
|
if event.nil?
|
169
|
-
|
169
|
+
log_debug("Discarded event because before_send_transaction returned nil")
|
170
170
|
transport.record_lost_event(:before_send, 'transaction')
|
171
171
|
return
|
172
172
|
end
|
@@ -177,11 +177,7 @@ module Sentry
|
|
177
177
|
|
178
178
|
event
|
179
179
|
rescue => e
|
180
|
-
|
181
|
-
log_error("#{loggable_event_type} sending failed", e, debug: configuration.debug)
|
182
|
-
|
183
|
-
event_info = Event.get_log_message(event.to_hash)
|
184
|
-
log_info("Unreported #{loggable_event_type}: #{event_info}")
|
180
|
+
log_error("Event sending failed", e, debug: configuration.debug)
|
185
181
|
transport.record_lost_event(:network_error, event_type)
|
186
182
|
raise
|
187
183
|
end
|
data/lib/sentry/configuration.rb
CHANGED
@@ -7,6 +7,7 @@ require 'sentry/utils/custom_inspection'
|
|
7
7
|
require "sentry/dsn"
|
8
8
|
require "sentry/release_detector"
|
9
9
|
require "sentry/transport/configuration"
|
10
|
+
require "sentry/cron/configuration"
|
10
11
|
require "sentry/linecache"
|
11
12
|
require "sentry/interfaces/stacktrace_builder"
|
12
13
|
|
@@ -226,10 +227,14 @@ module Sentry
|
|
226
227
|
# @return [String]
|
227
228
|
attr_accessor :server_name
|
228
229
|
|
229
|
-
#
|
230
|
-
# @return [Transport]
|
230
|
+
# Transport related configuration.
|
231
|
+
# @return [Transport::Configuration]
|
231
232
|
attr_reader :transport
|
232
233
|
|
234
|
+
# Cron related configuration.
|
235
|
+
# @return [Cron::Configuration]
|
236
|
+
attr_reader :cron
|
237
|
+
|
233
238
|
# Take a float between 0.0 and 1.0 as the sample rate for tracing events (transactions).
|
234
239
|
# @return [Float, nil]
|
235
240
|
attr_reader :traces_sample_rate
|
@@ -258,6 +263,12 @@ module Sentry
|
|
258
263
|
# @return [Boolean]
|
259
264
|
attr_accessor :auto_session_tracking
|
260
265
|
|
266
|
+
# Whether to downsample transactions automatically because of backpressure.
|
267
|
+
# Starts a new monitor thread to check health of the SDK every 10 seconds.
|
268
|
+
# Default is false
|
269
|
+
# @return [Boolean]
|
270
|
+
attr_accessor :enable_backpressure_handling
|
271
|
+
|
261
272
|
# Allowlist of outgoing request targets to which sentry-trace and baggage headers are attached.
|
262
273
|
# Default is all (/.*/)
|
263
274
|
# @return [Array<String, Regexp>]
|
@@ -358,6 +369,7 @@ module Sentry
|
|
358
369
|
self.skip_rake_integration = false
|
359
370
|
self.send_client_reports = true
|
360
371
|
self.auto_session_tracking = true
|
372
|
+
self.enable_backpressure_handling = false
|
361
373
|
self.trusted_proxies = []
|
362
374
|
self.dsn = ENV['SENTRY_DSN']
|
363
375
|
self.spotlight = false
|
@@ -373,6 +385,7 @@ module Sentry
|
|
373
385
|
self.enable_tracing = nil
|
374
386
|
|
375
387
|
@transport = Transport::Configuration.new
|
388
|
+
@cron = Cron::Configuration.new
|
376
389
|
@gem_specs = Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map)
|
377
390
|
|
378
391
|
run_post_initialization_callbacks
|
@@ -461,7 +474,7 @@ module Sentry
|
|
461
474
|
|
462
475
|
def profiles_sample_rate=(profiles_sample_rate)
|
463
476
|
raise ArgumentError, "profiles_sample_rate must be a Numeric or nil" unless is_numeric_or_nil?(profiles_sample_rate)
|
464
|
-
|
477
|
+
log_warn("Please make sure to include the 'stackprof' gem in your Gemfile to use Profiling with Sentry.") unless defined?(StackProf)
|
465
478
|
@profiles_sample_rate = profiles_sample_rate
|
466
479
|
end
|
467
480
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sentry
|
4
|
+
module Cron
|
5
|
+
class Configuration
|
6
|
+
# Defaults set here will apply to all {Cron::MonitorConfig} objects unless overwritten.
|
7
|
+
|
8
|
+
# How long (in minutes) after the expected checkin time will we wait
|
9
|
+
# until we consider the checkin to have been missed.
|
10
|
+
# @return [Integer, nil]
|
11
|
+
attr_accessor :default_checkin_margin
|
12
|
+
|
13
|
+
# How long (in minutes) is the checkin allowed to run for in in_progress
|
14
|
+
# before it is considered failed.
|
15
|
+
# @return [Integer, nil]
|
16
|
+
attr_accessor :default_max_runtime
|
17
|
+
|
18
|
+
# tz database style timezone string
|
19
|
+
# @return [String, nil]
|
20
|
+
attr_accessor :default_timezone
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -13,32 +13,42 @@ module Sentry
|
|
13
13
|
monitor_config: monitor_config)
|
14
14
|
|
15
15
|
start = Sentry.utc_now.to_i
|
16
|
-
# need to do this on ruby <= 2.6 sadly
|
17
|
-
ret = method(:perform).super_method.arity == 0 ? super() : super
|
18
|
-
duration = Sentry.utc_now.to_i - start
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
monitor_config: monitor_config)
|
17
|
+
begin
|
18
|
+
# need to do this on ruby <= 2.6 sadly
|
19
|
+
ret = method(:perform).super_method.arity == 0 ? super() : super
|
20
|
+
duration = Sentry.utc_now.to_i - start
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
Sentry.capture_check_in(slug,
|
23
|
+
:ok,
|
24
|
+
check_in_id: check_in_id,
|
25
|
+
duration: duration,
|
26
|
+
monitor_config: monitor_config)
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
duration: duration,
|
34
|
-
monitor_config: monitor_config)
|
28
|
+
ret
|
29
|
+
rescue Exception
|
30
|
+
duration = Sentry.utc_now.to_i - start
|
35
31
|
|
36
|
-
|
32
|
+
Sentry.capture_check_in(slug,
|
33
|
+
:error,
|
34
|
+
check_in_id: check_in_id,
|
35
|
+
duration: duration,
|
36
|
+
monitor_config: monitor_config)
|
37
|
+
|
38
|
+
raise
|
39
|
+
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
|
40
43
|
module ClassMethods
|
41
44
|
def sentry_monitor_check_ins(slug: nil, monitor_config: nil)
|
45
|
+
if monitor_config && Sentry.configuration
|
46
|
+
cron_config = Sentry.configuration.cron
|
47
|
+
monitor_config.checkin_margin ||= cron_config.default_checkin_margin
|
48
|
+
monitor_config.max_runtime ||= cron_config.default_max_runtime
|
49
|
+
monitor_config.timezone ||= cron_config.default_timezone
|
50
|
+
end
|
51
|
+
|
42
52
|
@sentry_monitor_slug = slug
|
43
53
|
@sentry_monitor_config = monitor_config
|
44
54
|
|
@@ -57,8 +67,6 @@ module Sentry
|
|
57
67
|
end
|
58
68
|
end
|
59
69
|
|
60
|
-
extend ClassMethods
|
61
|
-
|
62
70
|
def self.included(base)
|
63
71
|
base.extend(ClassMethods)
|
64
72
|
end
|
data/lib/sentry/event.rb
CHANGED
@@ -76,34 +76,6 @@ module Sentry
|
|
76
76
|
@message = (message || "").byteslice(0..MAX_MESSAGE_SIZE_IN_BYTES)
|
77
77
|
end
|
78
78
|
|
79
|
-
class << self
|
80
|
-
# @!visibility private
|
81
|
-
def get_log_message(event_hash)
|
82
|
-
message = event_hash[:message] || event_hash['message']
|
83
|
-
|
84
|
-
return message unless message.nil? || message.empty?
|
85
|
-
|
86
|
-
message = get_message_from_exception(event_hash)
|
87
|
-
|
88
|
-
return message unless message.nil? || message.empty?
|
89
|
-
|
90
|
-
message = event_hash[:transaction] || event_hash["transaction"]
|
91
|
-
|
92
|
-
return message unless message.nil? || message.empty?
|
93
|
-
|
94
|
-
'<no message value>'
|
95
|
-
end
|
96
|
-
|
97
|
-
# @!visibility private
|
98
|
-
def get_message_from_exception(event_hash)
|
99
|
-
if exception = event_hash.dig(:exception, :values, 0)
|
100
|
-
"#{exception[:type]}: #{exception[:value]}"
|
101
|
-
elsif exception = event_hash.dig("exception", "values", 0)
|
102
|
-
"#{exception["type"]}: #{exception["value"]}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
79
|
# @deprecated This method will be removed in v5.0.0. Please just use Sentry.configuration
|
108
80
|
# @return [Configuration]
|
109
81
|
def configuration
|
data/lib/sentry/hub.rb
CHANGED
@@ -156,7 +156,7 @@ module Sentry
|
|
156
156
|
capture_event(event, **options, &block)
|
157
157
|
end
|
158
158
|
|
159
|
-
def capture_check_in(slug, status, **options
|
159
|
+
def capture_check_in(slug, status, **options)
|
160
160
|
check_argument_type!(slug, ::String)
|
161
161
|
check_argument_includes!(status, Sentry::CheckInEvent::VALID_STATUSES)
|
162
162
|
|
@@ -176,7 +176,7 @@ module Sentry
|
|
176
176
|
|
177
177
|
return unless event
|
178
178
|
|
179
|
-
capture_event(event, **options
|
179
|
+
capture_event(event, **options)
|
180
180
|
event.check_in_id
|
181
181
|
end
|
182
182
|
|
data/lib/sentry/rake.rb
CHANGED
@@ -17,15 +17,6 @@ module Sentry
|
|
17
17
|
super
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
module Task
|
22
|
-
# @api private
|
23
|
-
def execute(args=nil)
|
24
|
-
return super unless Sentry.initialized? && Sentry.get_current_hub
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
28
|
-
end
|
29
20
|
end
|
30
21
|
end
|
31
22
|
|
@@ -34,8 +25,4 @@ module Rake
|
|
34
25
|
class Application
|
35
26
|
prepend(Sentry::Rake::Application)
|
36
27
|
end
|
37
|
-
|
38
|
-
class Task
|
39
|
-
prepend(Sentry::Rake::Task)
|
40
|
-
end
|
41
28
|
end
|
data/lib/sentry/scope.rb
CHANGED
@@ -44,12 +44,18 @@ module Sentry
|
|
44
44
|
# @param hint [Hash] the hint data that'll be passed to event processors.
|
45
45
|
# @return [Event]
|
46
46
|
def apply_to_event(event, hint = nil)
|
47
|
-
event.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
unless event.is_a?(CheckInEvent)
|
48
|
+
event.tags = tags.merge(event.tags)
|
49
|
+
event.user = user.merge(event.user)
|
50
|
+
event.extra = extra.merge(event.extra)
|
51
|
+
event.contexts = contexts.merge(event.contexts)
|
52
|
+
event.transaction = transaction_name if transaction_name
|
53
|
+
event.transaction_info = { source: transaction_source } if transaction_source
|
54
|
+
event.fingerprint = fingerprint
|
55
|
+
event.level = level
|
56
|
+
event.breadcrumbs = breadcrumbs
|
57
|
+
event.rack_env = rack_env if rack_env
|
58
|
+
end
|
53
59
|
|
54
60
|
if span
|
55
61
|
event.contexts[:trace] ||= span.get_trace_context
|
@@ -58,11 +64,6 @@ module Sentry
|
|
58
64
|
event.dynamic_sampling_context ||= propagation_context.get_dynamic_sampling_context
|
59
65
|
end
|
60
66
|
|
61
|
-
event.fingerprint = fingerprint
|
62
|
-
event.level = level
|
63
|
-
event.breadcrumbs = breadcrumbs
|
64
|
-
event.rack_env = rack_env if rack_env
|
65
|
-
|
66
67
|
all_event_processors = self.class.global_event_processors + @event_processors
|
67
68
|
|
68
69
|
unless all_event_processors.empty?
|
data/lib/sentry/transaction.rb
CHANGED
@@ -218,7 +218,12 @@ module Sentry
|
|
218
218
|
if sample_rate == true
|
219
219
|
@sampled = true
|
220
220
|
else
|
221
|
-
|
221
|
+
if Sentry.backpressure_monitor
|
222
|
+
factor = Sentry.backpressure_monitor.downsample_factor
|
223
|
+
@effective_sample_rate /= 2**factor
|
224
|
+
end
|
225
|
+
|
226
|
+
@sampled = Random.rand < @effective_sample_rate
|
222
227
|
end
|
223
228
|
|
224
229
|
if @sampled
|
@@ -257,7 +262,9 @@ module Sentry
|
|
257
262
|
event = hub.current_client.event_from_transaction(self)
|
258
263
|
hub.capture_event(event)
|
259
264
|
else
|
260
|
-
|
265
|
+
is_backpressure = Sentry.backpressure_monitor&.downsample_factor&.positive?
|
266
|
+
reason = is_backpressure ? :backpressure : :sample_rate
|
267
|
+
hub.current_client.transport.record_lost_event(reason, 'transaction')
|
261
268
|
end
|
262
269
|
end
|
263
270
|
|
@@ -53,18 +53,14 @@ module Sentry
|
|
53
53
|
end
|
54
54
|
|
55
55
|
if response.code.match?(/\A2\d{2}/)
|
56
|
-
if has_rate_limited_header?(response)
|
57
|
-
|
58
|
-
|
56
|
+
handle_rate_limited_response(response) if has_rate_limited_header?(response)
|
57
|
+
elsif response.code == "429"
|
58
|
+
log_debug("the server responded with status 429")
|
59
|
+
handle_rate_limited_response(response)
|
59
60
|
else
|
60
61
|
error_info = "the server responded with status #{response.code}"
|
61
|
-
|
62
|
-
|
63
|
-
handle_rate_limited_response(response)
|
64
|
-
else
|
65
|
-
error_info += "\nbody: #{response.body}"
|
66
|
-
error_info += " Error in headers is: #{response['x-sentry-error']}" if response['x-sentry-error']
|
67
|
-
end
|
62
|
+
error_info += "\nbody: #{response.body}"
|
63
|
+
error_info += " Error in headers is: #{response['x-sentry-error']}" if response['x-sentry-error']
|
68
64
|
|
69
65
|
raise Sentry::ExternalError, error_info
|
70
66
|
end
|
data/lib/sentry/transport.rb
CHANGED
@@ -19,7 +19,8 @@ module Sentry
|
|
19
19
|
:sample_rate,
|
20
20
|
:before_send,
|
21
21
|
:event_processor,
|
22
|
-
:insufficient_data
|
22
|
+
:insufficient_data,
|
23
|
+
:backpressure
|
23
24
|
]
|
24
25
|
|
25
26
|
include LoggingHelper
|
@@ -74,7 +75,7 @@ module Sentry
|
|
74
75
|
result, oversized = item.serialize
|
75
76
|
|
76
77
|
if oversized
|
77
|
-
|
78
|
+
log_debug("Envelope item [#{item.type}] is still oversized after size reduction: {#{item.size_breakdown}}")
|
78
79
|
|
79
80
|
next
|
80
81
|
end
|
@@ -119,6 +120,10 @@ module Sentry
|
|
119
120
|
!!delay && delay > Time.now
|
120
121
|
end
|
121
122
|
|
123
|
+
def any_rate_limited?
|
124
|
+
@rate_limits.values.any? { |t| t && t > Time.now }
|
125
|
+
end
|
126
|
+
|
122
127
|
def envelope_from_event(event)
|
123
128
|
# Convert to hash
|
124
129
|
event_payload = event.to_hash
|
@@ -163,11 +168,20 @@ module Sentry
|
|
163
168
|
@discarded_events[[reason, item_type]] += 1
|
164
169
|
end
|
165
170
|
|
171
|
+
def flush
|
172
|
+
client_report_headers, client_report_payload = fetch_pending_client_report(force: true)
|
173
|
+
return unless client_report_headers
|
174
|
+
|
175
|
+
envelope = Envelope.new
|
176
|
+
envelope.add_item(client_report_headers, client_report_payload)
|
177
|
+
send_envelope(envelope)
|
178
|
+
end
|
179
|
+
|
166
180
|
private
|
167
181
|
|
168
|
-
def fetch_pending_client_report
|
182
|
+
def fetch_pending_client_report(force: false)
|
169
183
|
return nil unless @send_client_reports
|
170
|
-
return nil if @last_client_report_sent > Time.now - CLIENT_REPORT_INTERVAL
|
184
|
+
return nil if !force && @last_client_report_sent > Time.now - CLIENT_REPORT_INTERVAL
|
171
185
|
return nil if @discarded_events.empty?
|
172
186
|
|
173
187
|
discarded_events_hash = @discarded_events.map do |key, val|
|
@@ -194,7 +208,7 @@ module Sentry
|
|
194
208
|
def reject_rate_limited_items(envelope)
|
195
209
|
envelope.items.reject! do |item|
|
196
210
|
if is_rate_limited?(item.type)
|
197
|
-
|
211
|
+
log_debug("[Transport] Envelope item [#{item.type}] not sent: rate limiting")
|
198
212
|
record_lost_event(:ratelimit_backoff, item.type)
|
199
213
|
|
200
214
|
true
|
data/lib/sentry/version.rb
CHANGED
data/lib/sentry-ruby.rb
CHANGED
@@ -21,6 +21,7 @@ require "sentry/transaction"
|
|
21
21
|
require "sentry/hub"
|
22
22
|
require "sentry/background_worker"
|
23
23
|
require "sentry/session_flusher"
|
24
|
+
require "sentry/backpressure_monitor"
|
24
25
|
require "sentry/cron/monitor_check_ins"
|
25
26
|
|
26
27
|
[
|
@@ -65,13 +66,17 @@ module Sentry
|
|
65
66
|
end
|
66
67
|
|
67
68
|
# @!attribute [rw] background_worker
|
68
|
-
# @return [BackgroundWorker
|
69
|
+
# @return [BackgroundWorker]
|
69
70
|
attr_accessor :background_worker
|
70
71
|
|
71
72
|
# @!attribute [r] session_flusher
|
72
73
|
# @return [SessionFlusher, nil]
|
73
74
|
attr_reader :session_flusher
|
74
75
|
|
76
|
+
# @!attribute [r] backpressure_monitor
|
77
|
+
# @return [BackpressureMonitor, nil]
|
78
|
+
attr_reader :backpressure_monitor
|
79
|
+
|
75
80
|
##### Patch Registration #####
|
76
81
|
|
77
82
|
# @!visibility private
|
@@ -217,17 +222,9 @@ module Sentry
|
|
217
222
|
Thread.current.thread_variable_set(THREAD_LOCAL, hub)
|
218
223
|
@main_hub = hub
|
219
224
|
@background_worker = Sentry::BackgroundWorker.new(config)
|
220
|
-
|
221
|
-
@
|
222
|
-
|
223
|
-
else
|
224
|
-
nil
|
225
|
-
end
|
226
|
-
|
227
|
-
if config.include_local_variables
|
228
|
-
exception_locals_tp.enable
|
229
|
-
end
|
230
|
-
|
225
|
+
@session_flusher = config.auto_session_tracking ? Sentry::SessionFlusher.new(config, client) : nil
|
226
|
+
@backpressure_monitor = config.enable_backpressure_handling ? Sentry::BackpressureMonitor.new(config, client) : nil
|
227
|
+
exception_locals_tp.enable if config.include_local_variables
|
231
228
|
at_exit { close }
|
232
229
|
end
|
233
230
|
|
@@ -236,20 +233,27 @@ module Sentry
|
|
236
233
|
#
|
237
234
|
# @return [void]
|
238
235
|
def close
|
239
|
-
if @background_worker
|
240
|
-
@background_worker.shutdown
|
241
|
-
@background_worker = nil
|
242
|
-
end
|
243
|
-
|
244
236
|
if @session_flusher
|
237
|
+
@session_flusher.flush
|
245
238
|
@session_flusher.kill
|
246
239
|
@session_flusher = nil
|
247
240
|
end
|
248
241
|
|
249
|
-
if
|
250
|
-
|
242
|
+
if @backpressure_monitor
|
243
|
+
@backpressure_monitor.kill
|
244
|
+
@backpressure_monitor = nil
|
251
245
|
end
|
252
246
|
|
247
|
+
if client = get_current_client
|
248
|
+
client.transport.flush
|
249
|
+
|
250
|
+
if client.configuration.include_local_variables
|
251
|
+
exception_locals_tp.disable
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
@background_worker.shutdown
|
256
|
+
|
253
257
|
@main_hub = nil
|
254
258
|
Thread.current.thread_variable_set(THREAD_LOCAL, nil)
|
255
259
|
end
|
@@ -442,12 +446,10 @@ module Sentry
|
|
442
446
|
# @option options [Integer] duration seconds elapsed since this monitor started
|
443
447
|
# @option options [Cron::MonitorConfig] monitor_config configuration for this monitor
|
444
448
|
#
|
445
|
-
# @yieldparam scope [Scope]
|
446
|
-
#
|
447
449
|
# @return [String, nil] The {CheckInEvent#check_in_id} to use for later updates on the same slug
|
448
|
-
def capture_check_in(slug, status, **options
|
450
|
+
def capture_check_in(slug, status, **options)
|
449
451
|
return unless initialized?
|
450
|
-
get_current_hub.capture_check_in(slug, status, **options
|
452
|
+
get_current_hub.capture_check_in(slug, status, **options)
|
451
453
|
end
|
452
454
|
|
453
455
|
# Takes or initializes a new Sentry::Transaction and makes a sampling decision for it.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- bin/setup
|
52
52
|
- lib/sentry-ruby.rb
|
53
53
|
- lib/sentry/background_worker.rb
|
54
|
+
- lib/sentry/backpressure_monitor.rb
|
54
55
|
- lib/sentry/backtrace.rb
|
55
56
|
- lib/sentry/baggage.rb
|
56
57
|
- lib/sentry/breadcrumb.rb
|
@@ -61,6 +62,7 @@ files:
|
|
61
62
|
- lib/sentry/configuration.rb
|
62
63
|
- lib/sentry/core_ext/object/deep_dup.rb
|
63
64
|
- lib/sentry/core_ext/object/duplicable.rb
|
65
|
+
- lib/sentry/cron/configuration.rb
|
64
66
|
- lib/sentry/cron/monitor_check_ins.rb
|
65
67
|
- lib/sentry/cron/monitor_config.rb
|
66
68
|
- lib/sentry/cron/monitor_schedule.rb
|