/
options.go
41 lines (34 loc) · 1.22 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
package tracer
import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
)
// Option allows to set custom options.
type Option func(*customOptions)
type customOptions struct {
jaegerResourceOptions []attribute.KeyValue
customErrorHandleFunc otel.ErrorHandlerFunc
}
// WithJaegerServiceName allows to set jaeger service name.
func WithJaegerServiceName(v string) Option {
return func(j *customOptions) {
j.jaegerResourceOptions = append(j.jaegerResourceOptions, semconv.ServiceName(v))
}
}
// WithJaegerServiceVersion allows to set jaeger service version.
func WithJaegerServiceVersion(v string) Option {
return func(j *customOptions) {
j.jaegerResourceOptions = append(j.jaegerResourceOptions, semconv.ServiceVersion(v))
}
}
// WithJaegerServiceEnv allows to set jaeger service environment.
func WithJaegerServiceEnv(v string) Option {
return func(j *customOptions) {
j.jaegerResourceOptions = append(j.jaegerResourceOptions, attribute.String("environment", v))
}
}
// WithCustomErrorHandler allows to set custom otel.ErrorHandlerFunc.
func WithCustomErrorHandler(v otel.ErrorHandlerFunc) Option {
return func(j *customOptions) { j.customErrorHandleFunc = v }
}