fixup tracing
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
0dfee57dd4
commit
44256cd62f
26
conn.go
26
conn.go
@ -99,9 +99,9 @@ func (w *wrapperConn) Begin() (driver.Tx, error) {
|
||||
|
||||
// BeginTx implements driver.ConnBeginTx BeginTx
|
||||
func (w *wrapperConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
|
||||
nctx, span := w.opts.Tracer.Start(ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
span.AddLabels("db.method", "BeginTx")
|
||||
name := getQueryName(ctx)
|
||||
nctx, span := w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
span.AddLabels("db.method", "BeginTx")
|
||||
span.AddLabels("db.statement", name)
|
||||
if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
|
||||
span.AddLabels("x-request-id", id)
|
||||
@ -173,13 +173,13 @@ func (w *wrapperConn) PrepareContext(ctx context.Context, query string) (driver.
|
||||
var nctx context.Context
|
||||
var span tracer.Span
|
||||
|
||||
name := getQueryName(ctx)
|
||||
if w.ctx != nil {
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
} else {
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
}
|
||||
span.AddLabels("db.method", "PrepareContext")
|
||||
name := getQueryName(ctx)
|
||||
span.AddLabels("db.statement", name)
|
||||
if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
|
||||
span.AddLabels("x-request-id", id)
|
||||
@ -252,13 +252,13 @@ func (w *wrapperConn) ExecContext(ctx context.Context, query string, args []driv
|
||||
var nctx context.Context
|
||||
var span tracer.Span
|
||||
|
||||
name := getQueryName(ctx)
|
||||
if w.ctx != nil {
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
} else {
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
}
|
||||
span.AddLabels("db.method", "ExecContext")
|
||||
name := getQueryName(ctx)
|
||||
span.AddLabels("db.statement", name)
|
||||
if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
|
||||
span.AddLabels("x-request-id", id)
|
||||
@ -311,9 +311,9 @@ func (w *wrapperConn) Ping(ctx context.Context) error {
|
||||
var nctx context.Context
|
||||
var span tracer.Span
|
||||
if w.ctx != nil {
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database Ping", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
} else {
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database Ping", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
}
|
||||
span.AddLabels("db.method", "Ping")
|
||||
defer span.Finish()
|
||||
@ -375,13 +375,13 @@ func (w *wrapperConn) QueryContext(ctx context.Context, query string, args []dri
|
||||
var nctx context.Context
|
||||
var span tracer.Span
|
||||
|
||||
name := getQueryName(ctx)
|
||||
if w.ctx != nil {
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
} else {
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
}
|
||||
span.AddLabels("db.method", "QueryContext")
|
||||
name := getQueryName(ctx)
|
||||
span.AddLabels("db.statement", name)
|
||||
if id, ok := ctx.Value(requestid.XRequestIDKey{}).(string); ok {
|
||||
span.AddLabels("x-request-id", id)
|
||||
|
12
stmt.go
12
stmt.go
@ -136,13 +136,13 @@ func (w *wrapperStmt) ExecContext(ctx context.Context, args []driver.NamedValue)
|
||||
var nctx context.Context
|
||||
var span tracer.Span
|
||||
|
||||
name := getQueryName(ctx)
|
||||
if w.ctx != nil {
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
} else {
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
}
|
||||
span.AddLabels("db.method", "ExecContext")
|
||||
name := getQueryName(ctx)
|
||||
span.AddLabels("db.statement", name)
|
||||
defer span.Finish()
|
||||
if len(args) > 0 {
|
||||
@ -209,13 +209,13 @@ func (w *wrapperStmt) QueryContext(ctx context.Context, args []driver.NamedValue
|
||||
var nctx context.Context
|
||||
var span tracer.Span
|
||||
|
||||
name := getQueryName(ctx)
|
||||
if w.ctx != nil {
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(w.ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
} else {
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database", tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
nctx, span = w.opts.Tracer.Start(ctx, "sdk.database "+name, tracer.WithSpanKind(tracer.SpanKindClient))
|
||||
}
|
||||
span.AddLabels("db.method", "QueryContext")
|
||||
name := getQueryName(ctx)
|
||||
span.AddLabels("db.statement", name)
|
||||
defer span.Finish()
|
||||
if len(args) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user