github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/sql_execer.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 // Execer interface is deprecated 13 14 type wExecer struct { 15 driver.Execer 16 connDetails DbConnDetails 17 sensor TracerLogger 18 } 19 20 func (conn *wExecer) Exec(query string, args []driver.Value) (driver.Result, error) { 21 ctx := context.Background() 22 sp, dbKey := startSQLSpan(ctx, conn.connDetails, query, conn.sensor) 23 defer sp.Finish() 24 25 res, err := conn.Execer.Exec(query, args) 26 27 if err != nil && err != driver.ErrSkip { 28 sp.LogFields(otlog.Error(err)) 29 sp.SetTag(dbKey+".error", err.Error()) 30 } 31 32 return res, err 33 }