Class: Sbmt::Outbox::Middleware::Sentry::TracingBatchProcessMiddleware

Inherits:
Object
  • Object
show all
Includes:
Transaction
Defined in:
lib/sbmt/outbox/middleware/sentry/tracing_batch_process_middleware.rb

Instance Method Summary collapse

Methods included from Transaction

#finish_sentry_transaction, #start_sentry_transaction

Instance Method Details

#call(job) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sbmt/outbox/middleware/sentry/tracing_batch_process_middleware.rb', line 12

def call(job)
  return yield unless ::Sentry.initialized?

  scope = ::Sentry.get_current_scope

  # transaction will be nil if sentry tracing is not enabled
  transaction = start_transaction(scope, job)

  begin
    yield
  rescue
    finish_sentry_transaction(scope, transaction, 500)
    raise
  end

  finish_sentry_transaction(scope, transaction, 200)
end