-
Notifications
You must be signed in to change notification settings - Fork 1k
/
options.go
46 lines (39 loc) · 1.24 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
package opentelemetry
// Options for opentelemetry:
type Options struct {
SamplingRate float64 // Percentage of requests to sample (0 = rely on propagated decision)
ServiceName string // The name of this service
TraceReporterAddress string // The address of a reporting server
}
type Option func(o *Options)
const (
defaultSamplingRate = float64(0)
defaultServiceName = "Micro"
defaultTraceReporterAddress = "localhost:6831"
)
// DefaultOptions returns default options:
func DefaultOptions() Options {
return Options{
SamplingRate: defaultSamplingRate,
ServiceName: defaultServiceName,
TraceReporterAddress: defaultTraceReporterAddress,
}
}
// WithSamplingRate configures the sampling rate:
func WithSamplingRate(samplingRate float64) Option {
return func(o *Options) {
o.SamplingRate = samplingRate
}
}
// WithServiceName configures the name of this service:
func WithServiceName(serviceName string) Option {
return func(o *Options) {
o.ServiceName = serviceName
}
}
// WithTraceReporterAddress configures the address of the trace reporter:
func WithTraceReporterAddress(traceReporterAddress string) Option {
return func(o *Options) {
o.TraceReporterAddress = traceReporterAddress
}
}