mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
chore: add tx metrics and logs for serialization errors (#15215)
Before db_metrics were all or nothing. Now `InTx` metrics are always recorded, and query metrics are opt in. Adds instrumentation & logging around serialization failures in the database.
This commit is contained in:
@ -365,7 +365,7 @@ func (tx *fakeTx) releaseLocks() {
|
||||
}
|
||||
|
||||
// InTx doesn't rollback data properly for in-memory yet.
|
||||
func (q *FakeQuerier) InTx(fn func(database.Store) error, _ *sql.TxOptions) error {
|
||||
func (q *FakeQuerier) InTx(fn func(database.Store) error, opts *database.TxOptions) error {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
tx := &fakeTx{
|
||||
@ -374,6 +374,9 @@ func (q *FakeQuerier) InTx(fn func(database.Store) error, _ *sql.TxOptions) erro
|
||||
}
|
||||
defer tx.releaseLocks()
|
||||
|
||||
if opts != nil {
|
||||
database.IncrementExecutionCount(opts)
|
||||
}
|
||||
return fn(tx)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user