bumps our uptrace/bun dependencies to v1.2.10 (#3865)

This commit is contained in:
kim 2025-03-03 10:42:05 +00:00 committed by tobi
commit 12d4d36bc8
37 changed files with 518 additions and 225 deletions

View file

@ -22,11 +22,12 @@ import (
)
type QueryHook struct {
attrs []attribute.KeyValue
formatQueries bool
tracer trace.Tracer
meter metric.Meter
queryHistogram metric.Int64Histogram
attrs []attribute.KeyValue
formatQueries bool
tracer trace.Tracer
meter metric.Meter
queryHistogram metric.Int64Histogram
spanNameFormatter func(*bun.QueryEvent) string
}
var _ bun.QueryHook = (*QueryHook)(nil)
@ -86,7 +87,11 @@ func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent) {
return
}
span.SetName(operation)
name := operation
if h.spanNameFormatter != nil {
name = h.spanNameFormatter(event)
}
span.SetName(name)
defer span.End()
query := h.eventQuery(event)
@ -106,9 +111,8 @@ func (h *QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent) {
attrs = append(attrs, sys)
}
if event.Result != nil {
if n, _ := event.Result.RowsAffected(); n > 0 {
attrs = append(attrs, attribute.Int64("db.rows_affected", n))
}
rows, _ := event.Result.RowsAffected()
attrs = append(attrs, attribute.Int64("db.rows_affected", rows))
}
switch event.Err {