forked from DataDog/dd-trace-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
30 lines (24 loc) · 770 Bytes
/
option.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
package mux
import "gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
type routerConfig struct {
serviceName string
spanOpts []ddtrace.StartSpanOption // additional span options to be applied
}
// RouterOption represents an option that can be passed to NewRouter.
type RouterOption func(*routerConfig)
func defaults(cfg *routerConfig) {
cfg.serviceName = "mux.router"
}
// WithServiceName sets the given service name for the router.
func WithServiceName(name string) RouterOption {
return func(cfg *routerConfig) {
cfg.serviceName = name
}
}
// WithSpanOptions applies the given set of options to the spans started
// by the router.
func WithSpanOptions(opts ...ddtrace.StartSpanOption) RouterOption {
return func(cfg *routerConfig) {
cfg.spanOpts = opts
}
}