Module: Sbmt::Outbox::Middleware::Sentry::Transaction

Included in:
TracingBatchProcessMiddleware, TracingItemProcessMiddleware
Defined in:
lib/sbmt/outbox/middleware/sentry/transaction.rb

Instance Method Summary collapse

Instance Method Details

#finish_sentry_transaction(scope, transaction, status) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/sbmt/outbox/middleware/sentry/transaction.rb', line 17

def finish_sentry_transaction(scope, transaction, status)
  return unless transaction

  transaction.set_http_status(status)
  transaction.finish
  scope.clear
end

#start_sentry_transaction(scope, op, name, tags = {}) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/sbmt/outbox/middleware/sentry/transaction.rb', line 8

def start_sentry_transaction(scope, op, name, tags = {})
  trace_id = SecureRandom.base58
  scope&.set_tags(tags.merge(trace_id: trace_id))
  transaction = ::Sentry.start_transaction(op: op, name: name)
  scope&.set_span(transaction) if transaction

  transaction
end