123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::TransactionInstrumenter

Class Method Summary

Instance Method Summary

Constructor Details

.new(payload = {}) ⇒ TransactionInstrumenter

[ GitHub ]

  
# File 'activerecord/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)

[ GitHub ]

  
# File 'activerecord/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

[ GitHub ]

  
# File 'activerecord/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