github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/sql_stmt_execer_context.go (about) 1 // (c) Copyright IBM Corp. 2023 2 3 package instana 4 5 import ( 6 "context" 7 "database/sql/driver" 8 9 otlog "github.com/opentracing/opentracing-go/log" 10 ) 11 12 type wStmtExecContext struct { 13 driver.StmtExecContext 14 connDetails DbConnDetails 15 sensor TracerLogger 16 query string 17 } 18 19 func (stmt *wStmtExecContext) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) { 20 sp, dbKey := startSQLSpan(ctx, stmt.connDetails, stmt.query, stmt.sensor) 21 defer sp.Finish() 22 23 res, err := stmt.StmtExecContext.ExecContext(ctx, args) 24 25 if err != nil && err != driver.ErrSkip { 26 sp.LogFields(otlog.Error(err)) 27 sp.SetTag(dbKey+".error", err.Error()) 28 } 29 30 return res, err 31 }