forked from jmoiron/sqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.go
More file actions
42 lines (37 loc) · 1.02 KB
/
common.go
File metadata and controls
42 lines (37 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package sqlx
import (
"context"
"errors"
"fmt"
"github.com/SkyAPM/go2sky"
agentv3 "skywalking.apache.org/repo/goapi/collect/language/agent/v3"
"strings"
)
const (
componentIDUnknown = 0
componentIDMysql = 5012
)
// ErrUnsupportedOp operation unsupported by the underlying driver
var ErrUnsupportedOp = errors.New("operation unsupported by the underlying driver")
func argsToString(args []interface{}) string {
sb := strings.Builder{}
for _, arg := range args {
sb.WriteString(fmt.Sprintf("%v, ", arg))
}
return sb.String()
}
func createSpan(ctx context.Context, tracer *go2sky.Tracer, opts *options, operation string) (go2sky.Span, error) {
s, _, err := tracer.CreateLocalSpan(ctx,
go2sky.WithSpanType(go2sky.SpanTypeExit),
go2sky.WithOperationName(opts.getOpName(operation)),
)
if err != nil {
return nil, err
}
s.SetPeer(opts.peer)
s.SetComponent(opts.componentID)
s.SetSpanLayer(agentv3.SpanLayer_Database)
s.Tag(go2sky.TagDBType, string(opts.dbType))
s.Tag(go2sky.TagDBInstance, opts.peer)
return s, nil
}