Skip to content

Commit

Permalink
fix: don't prefix query span name if disabled in TraceQueryStart an…
Browse files Browse the repository at this point in the history
…d `TracePrepareStart` (#35)

Signed-off-by: Nathanael DEMACON <[email protected]>
Co-authored-by: Nathanael DEMACON <[email protected]>
  • Loading branch information
quantumsheep and quantumsheep authored Jun 13, 2024
1 parent 0ffcf87 commit ae3a123
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ func (t *Tracer) TraceQueryStart(ctx context.Context, conn *pgx.Conn, data pgx.T
}
}

spanName := "query " + data.SQL
spanName := data.SQL
if t.trimQuerySpanName {
spanName = "query " + t.sqlOperationName(data.SQL)
spanName = t.sqlOperationName(data.SQL)
}
if t.prefixQuerySpanName {
spanName = "query " + spanName
}

ctx, _ = t.tracer.Start(ctx, spanName, opts...)
Expand Down Expand Up @@ -344,9 +347,12 @@ func (t *Tracer) TracePrepareStart(ctx context.Context, conn *pgx.Conn, data pgx
opts = append(opts, trace.WithAttributes(semconv.DBStatement(data.SQL)))
}

spanName := "prepare " + data.SQL
spanName := data.SQL
if t.trimQuerySpanName {
spanName = "prepare " + t.sqlOperationName(data.SQL)
spanName = t.sqlOperationName(data.SQL)
}
if t.prefixQuerySpanName {
spanName = "prepare " + spanName
}

ctx, _ = t.tracer.Start(ctx, spanName, opts...)
Expand Down

0 comments on commit ae3a123

Please sign in to comment.