Traces: Create span when a new session is opened (#61115)

This commit is contained in:
Yuri Tseretyan
2023-01-09 09:41:15 -05:00
committed by GitHub
parent e7b17cde47
commit 9f503a261a
2 changed files with 25 additions and 10 deletions
+7 -2
View File
@@ -34,7 +34,7 @@ func (ss *SQLStore) inTransactionWithRetry(ctx context.Context, fn func(ctx cont
}
func (ss *SQLStore) inTransactionWithRetryCtx(ctx context.Context, engine *xorm.Engine, bus bus.Bus, callback DBTransactionFunc, retry int) error {
sess, isNew, err := startSessionOrUseExisting(ctx, engine, true)
sess, isNew, span, err := startSessionOrUseExisting(ctx, engine, true, ss.tracer)
if err != nil {
return err
}
@@ -45,7 +45,12 @@ func (ss *SQLStore) inTransactionWithRetryCtx(ctx context.Context, engine *xorm.
}
if isNew { // if this call initiated the session, it should be responsible for closing it.
defer sess.Close()
defer func() {
if span != nil {
span.End()
}
sess.Close()
}()
}
err = callback(sess)