Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose background worker queue size #2195

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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