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

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