forked from DataDog/dd-trace-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
option.go
41 lines (34 loc) · 921 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
31
32
33
34
35
36
37
38
39
40
41
package restful
import "gopkg.in/DataDog/dd-trace-go.v1/internal/globalconfig"
type config struct {
serviceName string
analyticsRate float64
}
func newConfig() *config {
return &config{
serviceName: "go-restful",
analyticsRate: globalconfig.AnalyticsRate(),
}
}
// Option specifies instrumentation configuration options.
type Option func(*config)
// WithServiceName sets the service name to by used by the filter.
func WithServiceName(name string) Option {
return func(cfg *config) {
cfg.serviceName = name
}
}
// WithAnalytics enables Trace Analytics for all started spans.
func WithAnalytics(on bool) Option {
if on {
return WithAnalyticsRate(1.0)
}
return WithAnalyticsRate(0.0)
}
// WithAnalyticsRate sets the sampling rate for Trace Analytics events
// correlated to started spans.
func WithAnalyticsRate(rate float64) Option {
return func(cfg *config) {
cfg.analyticsRate = rate
}
}