/
options.go
78 lines (67 loc) · 2.05 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package lightstepoc
import (
"github.com/lightstep/lightstep-tracer-go"
"github.com/opentracing/opentracing-go"
)
// By default, the exporter will attempt to connect to a local satellite
const (
DefaultSatelliteHost = "localhost"
DefaultSatellitePort = 8360
)
// Option provides configuration for the Exporter
type Option func(*config)
// WithAccessToken sets an access token for communicating with LightStep
func WithAccessToken(accessToken string) Option {
return func(c *config) {
c.tracerOptions.AccessToken = accessToken
}
}
// WithSatelliteHost sets the satellite host to which spans will be sent
func WithSatelliteHost(satelliteHost string) Option {
return func(c *config) {
c.tracerOptions.Collector.Host = satelliteHost
}
}
// WithSatellitePort sets the satellite port to which spans will be sent
func WithSatellitePort(satellitePort int) Option {
return func(c *config) {
c.tracerOptions.Collector.Port = satellitePort
}
}
// WithInsecure prevents the Exporter from communicating over TLS with the satellite,
// i.e., the connection will run over HTTP instead of HTTPS
func WithInsecure(insecure bool) Option {
return func(c *config) {
c.tracerOptions.Collector.Plaintext = insecure
}
}
// WithMetaEventReportingEnabled configures the tracer to send meta events,
// e.g., events for span creation
func WithMetaEventReportingEnabled(metaEventReportingEnabled bool) Option {
return func(c *config) {
c.tracerOptions.MetaEventReportingEnabled = metaEventReportingEnabled
}
}
// WithComponentName overrides the component (service) name that will be used in LightStep
func WithComponentName(componentName string) Option {
return func(c *config) {
if componentName != "" {
c.tracerOptions.Tags[lightstep.ComponentNameKey] = componentName
}
}
}
type config struct {
tracerOptions lightstep.Options
}
func defaultConfig() *config {
return &config{
tracerOptions: lightstep.Options{
Collector: lightstep.Endpoint{
Host: DefaultSatelliteHost,
Port: DefaultSatellitePort,
},
Tags: make(opentracing.Tags),
UseHttp: true,
},
}
}