Skip to content

Commit

Permalink
fix: emit rows affected attribute (#33)
Browse files Browse the repository at this point in the history
Before this commit the `pgx.rows_affected` attribute would only be
emitted in case of error. The commit flips the check such that we emit
it when an error has not occurred.
  • Loading branch information
nordfjord authored May 21, 2024
1 parent c730c20 commit 32c5de8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (t *Tracer) TraceQueryEnd(ctx context.Context, _ *pgx.Conn, data pgx.TraceQ
span := trace.SpanFromContext(ctx)
recordError(span, data.Err)

if data.Err != nil {
if data.Err == nil {
span.SetAttributes(RowsAffectedKey.Int64(data.CommandTag.RowsAffected()))
}

Expand Down Expand Up @@ -204,7 +204,7 @@ func (t *Tracer) TraceCopyFromEnd(ctx context.Context, _ *pgx.Conn, data pgx.Tra
span := trace.SpanFromContext(ctx)
recordError(span, data.Err)

if data.Err != nil {
if data.Err == nil {
span.SetAttributes(RowsAffectedKey.Int64(data.CommandTag.RowsAffected()))
}

Expand Down

0 comments on commit 32c5de8

Please sign in to comment.