Class: ActiveRecord::ConnectionAdapters::TransactionInstrumenter
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::TransactionInstrumenter
- Defined in:
- lib/active_record/connection_adapters/abstract/transaction.rb
Defined Under Namespace
Classes: InstrumentationAlreadyStartedError, InstrumentationNotStartedError
Instance Method Summary collapse
- #finish(outcome) ⇒ Object
-
#initialize(payload = {}) ⇒ TransactionInstrumenter
constructor
A new instance of TransactionInstrumenter.
- #start ⇒ Object
Constructor Details
#initialize(payload = {}) ⇒ TransactionInstrumenter
Returns a new instance of TransactionInstrumenter.
78 79 80 81 82 83 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 78 def initialize(payload = {}) @handle = nil @started = false @payload = nil @base_payload = payload end |
Instance Method Details
#finish(outcome) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 97 def finish(outcome) raise InstrumentationNotStartedError.new("Called finish on a transaction that hasn't started") unless @started @started = false @payload[:outcome] = outcome @handle.finish end |
#start ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 88 def start raise InstrumentationAlreadyStartedError.new("Called start on an already started transaction") if @started @started = true @payload = @base_payload.dup @handle = ActiveSupport::Notifications.instrumenter.build_handle("transaction.active_record", @payload) @handle.start end |