Skip to content

Commit 9895426

Browse files
authored
Expose background worker queue size (#2195)
1 parent 50dc58a commit 9895426

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
### Features
4+
5+
- Expose `configuration.background_worker_max_queue` to control thread pool queue size [#2195](https://github.com/getsentry/sentry-ruby/pull/2195)
6+
17
## 5.15.0
28

39
### Features

sentry-ruby/lib/sentry/background_worker.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ class BackgroundWorker
1313
attr_reader :logger
1414
attr_accessor :shutdown_timeout
1515

16+
DEFAULT_MAX_QUEUE = 30
17+
1618
def initialize(configuration)
17-
@max_queue = 30
1819
@shutdown_timeout = 1
1920
@number_of_threads = configuration.background_worker_threads
21+
@max_queue = configuration.background_worker_max_queue
2022
@logger = configuration.logger
2123
@debug = configuration.debug
2224
@shutdown_callback = nil

sentry-ruby/lib/sentry/configuration.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ class Configuration
4040
# @return [Integer]
4141
attr_accessor :background_worker_threads
4242

43+
# The maximum queue size for the background worker.
44+
# Jobs will be rejected above this limit.
45+
#
46+
# Default is {BackgroundWorker::DEFAULT_MAX_QUEUE}.
47+
# @return [Integer]
48+
attr_accessor :background_worker_max_queue
49+
4350
# a proc/lambda that takes an array of stack traces
4451
# it'll be used to silence (reduce) backtrace of the exception
4552
#
@@ -329,6 +336,7 @@ def initialize
329336
self.app_dirs_pattern = nil
330337
self.debug = false
331338
self.background_worker_threads = Concurrent.processor_count
339+
self.background_worker_max_queue = BackgroundWorker::DEFAULT_MAX_QUEUE
332340
self.backtrace_cleanup_callback = nil
333341
self.max_breadcrumbs = BreadcrumbBuffer::DEFAULT_SIZE
334342
self.breadcrumbs_logger = []

0 commit comments

Comments
 (0)