Skip to content

Commit 050d742

Browse files
committed
readme change and re-order of commentsMap buildiing in go-sql.go
1 parent dcf70f4 commit 050d742

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

go/database/sql/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type CommenterOptions struct {
4040
EnableController bool // applicable for web frameworks
4141
EnableAction bool // applicable for web frameworks
4242
EnableApplication bool // applicable for web frameworks
43-
Application string // user-provided application-name. not required
43+
Application string // user-provided application-name. optional
4444
}
4545
```
4646

go/database/sql/go-sql.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,25 @@ func (db *DB) withComment(ctx context.Context, query string) string {
9595
commentsMap[core.Route] = ctx.Value(core.Route).(string)
9696
}
9797

98+
if db.options.EnableTraceparent {
99+
carrier := core.ExtractTraceparent(ctx)
100+
if val, ok := carrier["traceparent"]; ok {
101+
commentsMap[core.Traceparent] = val
102+
}
103+
}
104+
98105
if db.options.EnableApplication {
99106
if !attemptedToAutosetApplication && db.application == "" {
100107
attemptedToAutosetApplication = true
101108
bi, ok := debug.ReadBuildInfo()
102109
if ok {
103110
db.application = bi.Path
104-
} else {
105-
db.application = ""
106111
}
107112
}
108113

109114
commentsMap[core.Application] = db.application
110115
}
111116

112-
if db.options.EnableTraceparent {
113-
carrier := core.ExtractTraceparent(ctx)
114-
if val, ok := carrier["traceparent"]; ok {
115-
commentsMap[core.Traceparent] = val
116-
}
117-
}
118-
119117
var commentsString string = ""
120118
if len(commentsMap) > 0 { // Converts comments map to string and appends it to query
121119
commentsString = fmt.Sprintf("/*%s*/", core.ConvertMapToComment(commentsMap))

0 commit comments

Comments
 (0)