Module: Wurk::Sentry

Defined in:
lib/wurk/sentry.rb,
lib/wurk/sentry/middleware.rb,
lib/wurk/sentry/job_context.rb,
lib/wurk/sentry/retry_policy.rb,
lib/wurk/sentry/error_handler.rb

Overview

Opt-in Sentry integration. Not loaded by require "wurk" — pull it in explicitly and install it on the server config:

# config/initializers/wurk.rb
require "wurk/sentry"

Wurk.configure_server do |config|
Wurk::Sentry.install!(config)
end

This exists because sentry-sidekiq cannot be used with Wurk: its gemspec declares add_dependency "sidekiq", so Bundler installs real Sidekiq alongside Wurk and require "sidekiq" loads a broken hybrid. (The ecosystem/sidekiq-shim/ git source is the escape hatch for gems you must keep; see docs/sentry.md.)

sentry-ruby is not a runtime dependency — it is never required here, and every call site is guarded by Sentry.enabled?. Loading this file in an app without sentry-ruby, or before Sentry.init has run, is a no-op.

See docs/sentry.md.

Defined Under Namespace

Modules: JobContext, RetryPolicy Classes: ErrorHandler, Middleware

Class Method Summary collapse

Class Method Details

.enabled?Boolean

True only when sentry-ruby is loaded and Sentry.init has run. Guards every call into the SDK so the integration is inert by default.

Returns:

  • (Boolean)


53
54
55
# File 'lib/wurk/sentry.rb', line 53

def enabled?
  defined?(::Sentry) && ::Sentry.respond_to?(:initialized?) && ::Sentry.initialized?
end

.install!(config = Wurk.configuration, filter_transport_errors: true, filtered_error_classes: nil) ⇒ Wurk::Configuration

Registers the server middleware and the error handler. Idempotent: Chain#add dedupes by class, and a previously-installed ErrorHandler is replaced rather than stacked, so calling this twice (or calling it after an auto-install) never doubles a report.

Parameters:

  • config (Wurk::Configuration) (defaults to: Wurk.configuration)

    usually the block argument of Wurk.configure_server.

  • filter_transport_errors (Boolean) (defaults to: true)

    drop self-healing Redis / connection-pool errors instead of reporting them. See Wurk::Sentry::ErrorHandler::DEFAULT_FILTERED_ERROR_CLASSES.

  • filtered_error_classes (Array<Class>, nil) (defaults to: nil)

    replaces the default filter list. Extend it with Wurk::Sentry::ErrorHandler::DEFAULT_FILTERED_ERROR_CLASSES + [MyError].

Returns:



45
46
47
48
49
# File 'lib/wurk/sentry.rb', line 45

def install!(config = Wurk.configuration, filter_transport_errors: true, filtered_error_classes: nil)
  config.server_middleware.add(Middleware)
  install_error_handler(config, filter_transport_errors, filtered_error_classes)
  config
end