-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
options.go
39 lines (33 loc) · 1000 Bytes
/
options.go
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
package sqlcon
type options struct {
UseTracedDriver bool
OmitArgs bool
AllowRoot bool
forcedDriverName string
}
type Opt func(*options)
// WithDistributedTracing will make it so that a wrapped driver is used that supports the opentracing API
func WithDistributedTracing() Opt {
return func(o *options) {
o.UseTracedDriver = true
}
}
// WithOmitArgsFromTraceSpans will make it so that query arguments are omitted from tracing spans
func WithOmitArgsFromTraceSpans() Opt {
return func(o *options) {
o.OmitArgs = true
}
}
// WithAllowRoot will make it so that root spans will be created if a trace could not be found using
// opentracing's SpanFromContext method
func WithAllowRoot() Opt {
return func(o *options) {
o.AllowRoot = true
}
}
// This option is specifically for writing tests as you can't register a driver with the same name more than once
func WithRandomDriverName() Opt {
return func(o *options) {
o.forcedDriverName = uuid.NewV4().String()
}
}