Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions operation_name_go124.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import (
"strings"
)

// sqlOperationName attempts to get the first 'word' from a given SQL query, which usually
// defaultSpanNameFunc attempts to get the first 'word' from a given SQL query, which usually
// is the operation name (e.g. 'SELECT').
func (t *Tracer) sqlOperationName(stmt string) string {
if t.spanNameFunc != nil {
return t.spanNameFunc(stmt)
}

func defaultSpanNameFunc(stmt string) string {
for word := range strings.FieldsSeq(stmt) {
return strings.ToUpper(word)
}
Expand Down
11 changes: 2 additions & 9 deletions operation_name_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@ import (
"unicode"
)

// sqlOperationName attempts to get the first 'word' from a given SQL query, which usually
// defaultSpanNameFunc attempts to get the first 'word' from a given SQL query, which usually
// is the operation name (e.g. 'SELECT').
func (t *Tracer) sqlOperationName(stmt string) string {
// If a custom function is provided, use that. Otherwise, fall back to the
// default implementation. This allows users to override the default
// behavior without having to reimplement it.
if t.spanNameFunc != nil {
return t.spanNameFunc(stmt)
}

func defaultSpanNameFunc(stmt string) string {
stmt = strings.TrimSpace(stmt)
end := strings.IndexFunc(stmt, unicode.IsSpace)
if end < 0 && len(stmt) > 0 {
Expand Down
Loading