-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
options.go
43 lines (36 loc) · 1.02 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
package tracefs
import (
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
)
// Option specifies instrumentation configuration options.
type Option interface {
apply(c *config)
}
type config struct {
propagators propagation.TextMapPropagator
tp trace.TracerProvider
}
type optionFunc func(*config)
func (o optionFunc) apply(c *config) {
o(c)
}
// WithPropagators specifies propagators to use for extracting
// information from the HTTP requests. If none are specified, global
// ones will be used.
func WithPropagators(propagators propagation.TextMapPropagator) Option {
return optionFunc(func(cfg *config) {
if propagators != nil {
cfg.propagators = propagators
}
})
}
// WithTracerProvider specifies a tracer provider to use for creating a tracer.
// If none is specified, the global provider is used (see [otel.GetTracerProvider]).
func WithTracerProvider(provider trace.TracerProvider) Option {
return optionFunc(func(cfg *config) {
if provider != nil {
cfg.tp = provider
}
})
}