[chore]: Bump github.com/uptrace/bun/extra/bunotel from 1.2.9 to 1.2.10

Bumps [github.com/uptrace/bun/extra/bunotel](https://github.com/uptrace/bun) from 1.2.9 to 1.2.10.
- [Release notes](https://github.com/uptrace/bun/releases)
- [Changelog](https://github.com/uptrace/bun/blob/master/CHANGELOG.md)
- [Commits](https://github.com/uptrace/bun/compare/v1.2.9...v1.2.10)

---
updated-dependencies:
- dependency-name: github.com/uptrace/bun/extra/bunotel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot] 2025-03-03 06:28:03 +00:00 committed by GitHub
commit 78e03263ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 417 additions and 204 deletions

View file

@ -1,6 +1,7 @@
package bun
import (
"context"
"fmt"
"reflect"
"strings"
@ -86,3 +87,26 @@ func appendComment(b []byte, name string) []byte {
name = strings.ReplaceAll(name, `*/`, `*\/`)
return append(b, fmt.Sprintf("/* %s */ ", name)...)
}
// queryCommentCtxKey is a context key for setting a query comment on a context instead of calling the Comment("...") API directly
type queryCommentCtxKey struct{}
// WithComment returns a context that includes a comment that may be included in a query for debugging
//
// If a context with an attached query is used, a comment set by the Comment("...") API will be overwritten.
func WithComment(ctx context.Context, comment string) context.Context {
return context.WithValue(ctx, queryCommentCtxKey{}, comment)
}
// commenter describes the Comment interface implemented by all of the query types
type commenter[T any] interface {
Comment(string) T
}
// setCommentFromContext sets the comment on the given query from the supplied context if one is set using the Comment(...) method.
func setCommentFromContext[T any](ctx context.Context, q commenter[T]) {
s, _ := ctx.Value(queryCommentCtxKey{}).(string)
if s != "" {
q.Comment(s)
}
}