Class: Sbmt::Outbox::Middleware::Sentry::TracingItemProcessMiddleware
- Inherits:
-
Object
- Object
- Sbmt::Outbox::Middleware::Sentry::TracingItemProcessMiddleware
- Includes:
- Transaction
- Defined in:
- lib/sbmt/outbox/middleware/sentry/tracing_item_process_middleware.rb
Instance Attribute Summary collapse
-
#new_transaction ⇒ Object
readonly
Returns the value of attribute new_transaction.
Instance Method Summary collapse
Methods included from Transaction
#finish_sentry_transaction, #start_sentry_transaction
Instance Attribute Details
#new_transaction ⇒ Object (readonly)
Returns the value of attribute new_transaction.
12 13 14 |
# File 'lib/sbmt/outbox/middleware/sentry/tracing_item_process_middleware.rb', line 12 def new_transaction @new_transaction end |
Instance Method Details
#call(item) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sbmt/outbox/middleware/sentry/tracing_item_process_middleware.rb', line 14 def call(item) return yield unless ::Sentry.initialized? scope = ::Sentry.get_current_scope # transaction will be nil if sentry tracing is not enabled transaction = scope&.get_transaction || start_transaction(scope, item.class) span = transaction&.start_child(op: op(item.class), description: "Starting item processing") span&.set_data(:item_id, item.id) begin yield rescue finish_span(span, 500) finish_sentry_transaction(scope, transaction, 500) if new_transaction raise end finish_span(span, 200) finish_sentry_transaction(scope, transaction, 200) if new_transaction end |