...
1 package opentracing
2
3 import (
4 "context"
5
6 "github.com/opentracing/opentracing-go"
7 )
8
9
10 type EndpointOptions struct {
11
12
13 IgnoreBusinessError bool
14
15
16
17
18
19 GetOperationName func(ctx context.Context, name string) string
20
21
22
23 Tags opentracing.Tags
24
25
26
27 GetTags func(ctx context.Context) opentracing.Tags
28 }
29
30
31 type EndpointOption func(*EndpointOptions)
32
33
34 func WithOptions(options EndpointOptions) EndpointOption {
35 return func(o *EndpointOptions) {
36 *o = options
37 }
38 }
39
40
41
42 func WithIgnoreBusinessError(ignoreBusinessError bool) EndpointOption {
43 return func(o *EndpointOptions) {
44 o.IgnoreBusinessError = ignoreBusinessError
45 }
46 }
47
48
49
50 func WithOperationNameFunc(getOperationName func(ctx context.Context, name string) string) EndpointOption {
51 return func(o *EndpointOptions) {
52 o.GetOperationName = getOperationName
53 }
54 }
55
56
57 func WithTags(tags opentracing.Tags) EndpointOption {
58 return func(o *EndpointOptions) {
59 if o.Tags == nil {
60 o.Tags = make(opentracing.Tags)
61 }
62
63 for key, value := range tags {
64 o.Tags[key] = value
65 }
66 }
67 }
68
69
70 func WithTagsFunc(getTags func(ctx context.Context) opentracing.Tags) EndpointOption {
71 return func(o *EndpointOptions) {
72 o.GetTags = getTags
73 }
74 }
75
View as plain text