Module: Gitlab::Database::ActiveRecordBaseTransactionMetrics

Defined in:
lib/gitlab/database.rb

Overview

MonkeyPatch for ActiveRecord::Base for adding observability

Instance Method Summary collapse

Instance Method Details

#transaction(options = {}, &block) ⇒ Object

A monkeypatch over ActiveRecord::Base.transaction. It provides observability into transactional methods.


345
346
347
348
349
350
# File 'lib/gitlab/database.rb', line 345

def transaction(options = {}, &block)
  start_time = Gitlab::Metrics::System.monotonic_time
  super(options, &block)
ensure
  Gitlab::Database.observe_transaction_duration(Gitlab::Metrics::System.monotonic_time - start_time)
end