Traces: Create span when a new session is opened (#61115)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user