go.undefinedlabs.com/scopeagent@v0.4.2/instrumentation/sql/tx.go (about)

     1  package sql
     2  
     3  import (
     4  	"database/sql/driver"
     5  	"github.com/opentracing/opentracing-go"
     6  )
     7  
     8  // conn defines a tracing wrapper for driver.Tx.
     9  type instrumentedTx struct {
    10  	tx            driver.Tx
    11  	configuration *driverConfiguration
    12  	span          opentracing.Span
    13  }
    14  
    15  // Commit implements driver.Tx Commit.
    16  func (t *instrumentedTx) Commit() error {
    17  	if t.span != nil {
    18  		defer t.span.Finish()
    19  	}
    20  	return t.tx.Commit()
    21  }
    22  
    23  // Rollback implements driver.Tx Rollback.
    24  func (t *instrumentedTx) Rollback() error {
    25  	if t.span != nil {
    26  		defer t.span.Finish()
    27  	}
    28  	return t.tx.Rollback()
    29  }