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:
Steven Masley
2024-10-25 12:14:15 -04:00
committed by GitHub
parent df34858c3c
commit ccfffc6911
32 changed files with 3123 additions and 2800 deletions

View File

@ -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)
}