@@ -393,27 +393,28 @@ func (c *ocConn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.
393393
394394 var span * trace.Span
395395 attrs := append ([]trace.Attribute (nil ), c .options .DefaultAttributes ... )
396- defer func () {
397- if len (attrs ) > 0 {
398- span .AddAttributes (attrs ... )
399- }
400- }()
396+
401397 if ctx == nil || ctx == context .TODO () {
402398 ctx = context .Background ()
403399 _ , span = trace .StartSpan (ctx , "sql:begin_transaction" , trace .WithSpanKind (trace .SpanKindClient ))
404400 attrs = append (attrs , attrMissingContext )
405401 } else {
406402 _ , span = trace .StartSpan (ctx , "sql:begin_transaction" , trace .WithSpanKind (trace .SpanKindClient ))
407403 }
408- defer span .End ()
404+ defer func () {
405+ if len (attrs ) > 0 {
406+ span .AddAttributes (attrs ... )
407+ }
408+ span .End ()
409+ }()
409410
410411 if connBeginTx , ok := c .parent .(driver.ConnBeginTx ); ok {
411412 tx , err = connBeginTx .BeginTx (ctx , opts )
412413 setSpanStatus (span , err )
413414 if err != nil {
414415 return nil , err
415416 }
416- return ocTx {parent : tx , ctx : ctx }, nil
417+ return ocTx {parent : tx , ctx : ctx , options : c . options }, nil
417418 }
418419
419420 attrs = append (
@@ -428,7 +429,7 @@ func (c *ocConn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.
428429 if err != nil {
429430 return nil , err
430431 }
431- return ocTx {parent : tx , ctx : ctx }, nil
432+ return ocTx {parent : tx , ctx : ctx , options : c . options }, nil
432433}
433434
434435// ocResult implements driver.Result
0 commit comments