Skip to content

Commit

Permalink
Add godoc and move main function to top
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-normand committed Mar 30, 2022
1 parent 07f4596 commit 00d3a32
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ddtrace/tracer/sqlcomment.go
Expand Up @@ -7,10 +7,19 @@ import (
"strings"
)

// SQLCommentCarrier holds tags to be serialized as a SQL Comment
type SQLCommentCarrier struct {
tags map[string]string
}

// Set implements TextMapWriter.
func (c *SQLCommentCarrier) Set(key, val string) {
if c.tags == nil {
c.tags = make(map[string]string)
}
c.tags[key] = val
}

func commentWithTags(tags map[string]string) (comment string) {
if len(tags) == 0 {
return ""
Expand All @@ -26,14 +35,8 @@ func commentWithTags(tags map[string]string) (comment string) {
return fmt.Sprintf("/* %s */", comment)
}

// Set implements TextMapWriter.
func (c *SQLCommentCarrier) Set(key, val string) {
if c.tags == nil {
c.tags = make(map[string]string)
}
c.tags[key] = val
}

// CommentedQuery returns the given query with the tags from the SQLCommentCarrier applied to it as a
// prepended SQL comment
func (c *SQLCommentCarrier) CommentedQuery(query string) (commented string) {
comment := commentWithTags(c.tags)

Expand Down

0 comments on commit 00d3a32

Please sign in to comment.