mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +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:
@ -735,9 +735,9 @@ func expectDB(t *testing.T, opts ...txExpect) *dbmock.MockStore {
|
||||
// we expect to be run in a transaction; we use mTx to record the
|
||||
// "in transaction" calls.
|
||||
mDB.EXPECT().InTx(
|
||||
gomock.Any(), gomock.Eq(&sql.TxOptions{Isolation: sql.LevelRepeatableRead}),
|
||||
gomock.Any(), gomock.Eq(&database.TxOptions{Isolation: sql.LevelRepeatableRead}),
|
||||
).
|
||||
DoAndReturn(func(f func(database.Store) error, _ *sql.TxOptions) error {
|
||||
DoAndReturn(func(f func(database.Store) error, _ *database.TxOptions) error {
|
||||
err := f(mTx)
|
||||
return err
|
||||
})
|
||||
@ -763,7 +763,7 @@ func withTemplate(mTx *dbmock.MockStore) {
|
||||
// withInTx runs the given functions on the same db mock.
|
||||
func withInTx(mTx *dbmock.MockStore) {
|
||||
mTx.EXPECT().InTx(gomock.Any(), gomock.Any()).Times(1).DoAndReturn(
|
||||
func(f func(store database.Store) error, _ *sql.TxOptions) error {
|
||||
func(f func(store database.Store) error, _ *database.TxOptions) error {
|
||||
return f(mTx)
|
||||
},
|
||||
)
|
||||
|
Reference in New Issue
Block a user