Skip to content

Commit

Permalink
Expose background worker queue size (#2195)
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Dec 11, 2023
1 parent 50dc58a commit 9895426
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Features

- Expose `configuration.background_worker_max_queue` to control thread pool queue size [#2195](https://github.com/getsentry/sentry-ruby/pull/2195)

## 5.15.0

### Features
Expand Down
4 changes: 3 additions & 1 deletion sentry-ruby/lib/sentry/background_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class BackgroundWorker
attr_reader :logger
attr_accessor :shutdown_timeout

DEFAULT_MAX_QUEUE = 30

def initialize(configuration)
@max_queue = 30
@shutdown_timeout = 1
@number_of_threads = configuration.background_worker_threads
@max_queue = configuration.background_worker_max_queue
@logger = configuration.logger
@debug = configuration.debug
@shutdown_callback = nil
Expand Down
8 changes: 8 additions & 0 deletions sentry-ruby/lib/sentry/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ class Configuration
# @return [Integer]
attr_accessor :background_worker_threads

# The maximum queue size for the background worker.
# Jobs will be rejected above this limit.
#
# Default is {BackgroundWorker::DEFAULT_MAX_QUEUE}.
# @return [Integer]
attr_accessor :background_worker_max_queue

# a proc/lambda that takes an array of stack traces
# it'll be used to silence (reduce) backtrace of the exception
#
Expand Down Expand Up @@ -329,6 +336,7 @@ def initialize
self.app_dirs_pattern = nil
self.debug = false
self.background_worker_threads = Concurrent.processor_count
self.background_worker_max_queue = BackgroundWorker::DEFAULT_MAX_QUEUE
self.backtrace_cleanup_callback = nil
self.max_breadcrumbs = BreadcrumbBuffer::DEFAULT_SIZE
self.breadcrumbs_logger = []
Expand Down

0 comments on commit 9895426

Please sign in to comment.