-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tracing): support tracing like
OpenTracing
with options
- Loading branch information
SianLoong
committed
May 1, 2020
1 parent
255fab2
commit 498c5ee
Showing
16 changed files
with
437 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package opentracing | ||
|
||
import ( | ||
"database/sql" | ||
"database/sql/driver" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/opentracing/opentracing-go" | ||
"github.com/opentracing/opentracing-go/log" | ||
) | ||
|
||
func logArgs(span opentracing.Span, args []driver.NamedValue) { | ||
fields := make([]log.Field, len(args)) | ||
for i, arg := range args { | ||
switch v := arg.Value.(type) { | ||
case string: | ||
fields[i] = log.String(arg.Name, v) | ||
case int64: | ||
fields[i] = log.Int64(arg.Name, v) | ||
case uint64: | ||
fields[i] = log.Uint64(arg.Name, v) | ||
case float64: | ||
fields[i] = log.Float64(arg.Name, v) | ||
case bool: | ||
fields[i] = log.Bool(arg.Name, v) | ||
case time.Time: | ||
fields[i] = log.String(arg.Name, v.Format(time.RFC3339)) | ||
case []byte: | ||
fields[i] = log.String(arg.Name, string(v)) | ||
case sql.RawBytes: | ||
fields[i] = log.String(arg.Name, string(v)) | ||
case nil: | ||
fields[i] = log.String(arg.Name, "null") | ||
default: | ||
fields[i] = log.String(arg.Name, fmt.Sprintf("%v", v)) | ||
} | ||
} | ||
span.LogFields(fields...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.