Class: Wurk::Sentry::Middleware
- Inherits:
-
Object
- Object
- Wurk::Sentry::Middleware
- Includes:
- Middleware::ServerMiddleware
- Defined in:
- lib/wurk/sentry/middleware.rb
Overview
Server middleware: scopes every job for Sentry, and reports the job's terminal failure.
Both halves are needed because a job failure never reaches
config.error_handlers. JobRetry#local rescues the exception, books
the retry, and raises JobRetry::Handled, which Processor#process
swallows — so an error handler alone sees fetch-loop errors and nothing
else. The middleware runs inside JobRetry#local (see
Processor#dispatch), which is the only place the raw exception is
still in flight.
The exception is always re-raised: Wurk's retry pipeline, not this middleware, owns the failure.
Instance Attribute Summary
Attributes included from Middleware::ServerMiddleware
Instance Method Summary collapse
Methods included from Middleware::ServerMiddleware
Instance Method Details
#call(instance, job, queue, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/wurk/sentry/middleware.rb', line 26 def call(instance, job, queue, &block) return yield unless Wurk::Sentry.enabled? # Each Processor owns a thread, and Sentry's hub is thread-local. # Without this the worker thread starts from an empty hub and the # scope set below is invisible to the capture. ::Sentry.clone_hub_to_current_thread ::Sentry.with_scope do |scope| JobContext.apply(scope, job, queue) monitor(instance, job, &block) end end |