Skip to content

Commit

Permalink
Merge pull request #96 from honeycombio/ben.error_strings
Browse files Browse the repository at this point in the history
[sqlx] Adding an error interface does not stringify by default. Explicitly use the error string
  • Loading branch information
maplebed authored Feb 26, 2020
2 parents c8c291d + b4af0ac commit bc39f9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions wrappers/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func BuildDBEvent(bld *libhoney.Builder, stats sql.DBStats, query string, args .
// rollup(ctx, ev, duration)
ev.AddField("duration_ms", duration)
if err != nil {
ev.AddField("db.error", err)
ev.AddField("db.error", err.Error())
}
ev.Metadata, _ = ev.Fields()["name"]
ev.Send()
Expand Down Expand Up @@ -199,7 +199,7 @@ func BuildDBSpan(ctx context.Context, bld *libhoney.Builder, stats sql.DBStats,
fn := func(err error) {
duration := timer.Finish()
if err != nil {
span.AddField("db.error", err)
span.AddField("db.error", err.Error())
}
span.AddRollupField("db.duration_ms", duration)
span.AddRollupField("db.call_count", 1)
Expand Down
20 changes: 10 additions & 10 deletions wrappers/hnysqlx/sqlx.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (db *DB) MustBegin() *Tx {
wrapTx.wtx = tx

if err != nil {
ev.AddField("db.panic", err)
ev.AddField("db.panic", err.Error())
panic(err)
}
return wrapTx
Expand Down Expand Up @@ -304,7 +304,7 @@ func (db *DB) MustBeginTx(ctx context.Context, opts *sql.TxOptions) *Tx {
// manually wrap the panic in order to report it
if err != nil {
if span != nil {
span.AddField("db.panic", err)
span.AddField("db.panic", err.Error())
}
panic(err)
}
Expand All @@ -328,7 +328,7 @@ func (db *DB) MustExec(query string, args ...interface{}) sql.Result {

// manually wrap the panic in order to report it
if err != nil {
ev.AddField("db.panic", err)
ev.AddField("db.panic", err.Error())
panic(err)
}

Expand Down Expand Up @@ -363,7 +363,7 @@ func (db *DB) MustExecContext(ctx context.Context, query string, args ...interfa
// manually wrap the panic in order to report it
if err != nil {
if span != nil {
span.AddField("db.panic", err)
span.AddField("db.panic", err.Error())
}
panic(err)
}
Expand Down Expand Up @@ -1025,7 +1025,7 @@ func (n *NamedStmt) MustExec(arg interface{}) sql.Result {

// manually wrap the panic in order to report it
if err != nil {
ev.AddField("db.panic", err)
ev.AddField("db.panic", err.Error())
panic(err)
}

Expand Down Expand Up @@ -1054,7 +1054,7 @@ func (n *NamedStmt) MustExecContext(ctx context.Context, arg interface{}) sql.Re
// manually wrap the panic in order to report it
if err != nil {
if span != nil {
span.AddField("db.panic", err)
span.AddField("db.panic", err.Error())
}
panic(err)
}
Expand Down Expand Up @@ -1277,7 +1277,7 @@ func (s *Stmt) MustExec(args ...interface{}) sql.Result {

// manually wrap the panic in order to report it
if err != nil {
ev.AddField("db.panic", err)
ev.AddField("db.panic", err.Error())
panic(err)
}

Expand Down Expand Up @@ -1311,7 +1311,7 @@ func (s *Stmt) MustExecContext(ctx context.Context, args ...interface{}) sql.Res
// manually wrap the panic in order to report it
if err != nil {
if span != nil {
span.AddField("db.panic", err)
span.AddField("db.panic", err.Error())
}
panic(err)
}
Expand Down Expand Up @@ -1662,7 +1662,7 @@ func (tx *Tx) MustExec(query string, args ...interface{}) sql.Result {

// manually wrap the panic in order to report it
if err != nil {
ev.AddField("db.panic", err)
ev.AddField("db.panic", err.Error())
panic(err)
}

Expand Down Expand Up @@ -1696,7 +1696,7 @@ func (tx *Tx) MustExecContext(ctx context.Context, query string, args ...interfa
// manually wrap the panic in order to report it
if err != nil {
if span != nil {
span.AddField("db.panic", err)
span.AddField("db.panic", err.Error())
}
panic(err)
}
Expand Down

0 comments on commit bc39f9e

Please sign in to comment.