chore: refactor (#1814)

This commit is contained in:
Kevin Wan
2022-04-22 09:37:09 +08:00
committed by GitHub
parent 162e9cef86
commit bc3c9484d1
5 changed files with 32 additions and 20 deletions

View File

@@ -11,6 +11,9 @@ import (
tracesdk "go.opentelemetry.io/otel/trace"
)
// spanName is used to identify the span name for the SQL execution.
const spanName = "sql"
// ErrNotFound is an alias of sql.ErrNoRows
var ErrNotFound = sql.ErrNoRows
@@ -240,7 +243,6 @@ func (db *commonSqlConn) QueryRowsPartialCtx(ctx context.Context, v interface{},
return db.queryRows(ctx, func(rows *sql.Rows) error {
return unmarshalRows(v, rows, false)
}, q, args...)
}
func (db *commonSqlConn) RawDB() (*sql.DB, error) {
@@ -362,5 +364,5 @@ func (s statement) QueryRowsPartialCtx(ctx context.Context, v interface{}, args
func startSpan(ctx context.Context) (context.Context, tracesdk.Span) {
tracer := otel.GetTracerProvider().Tracer(trace.TraceName)
return tracer.Start(ctx, "sql")
return tracer.Start(ctx, spanName)
}