...
1 package opencensus
2
3 import (
4 "go.opencensus.io/plugin/ochttp/propagation/b3"
5 "go.opencensus.io/trace"
6 "go.opencensus.io/trace/propagation"
7 )
8
9
10
11 var defaultHTTPPropagate propagation.HTTPFormat = &b3.HTTPFormat{}
12
13
14
15 type TracerOption func(o *TracerOptions)
16
17
18 func WithTracerConfig(options TracerOptions) TracerOption {
19 return func(o *TracerOptions) {
20 *o = options
21 }
22 }
23
24
25 func WithSampler(sampler trace.Sampler) TracerOption {
26 return func(o *TracerOptions) {
27 o.Sampler = sampler
28 }
29 }
30
31
32
33
34 func WithName(name string) TracerOption {
35 return func(o *TracerOptions) {
36 o.Name = name
37 }
38 }
39
40
41
42
43
44
45 func IsPublic(isPublic bool) TracerOption {
46 return func(o *TracerOptions) {
47 o.Public = isPublic
48 }
49 }
50
51
52
53 func WithHTTPPropagation(p propagation.HTTPFormat) TracerOption {
54 return func(o *TracerOptions) {
55 if p == nil {
56
57 o.HTTPPropagate = defaultHTTPPropagate
58 return
59 }
60 o.HTTPPropagate = p
61 }
62 }
63
64
65 type TracerOptions struct {
66 Sampler trace.Sampler
67 Name string
68 Public bool
69 HTTPPropagate propagation.HTTPFormat
70 }
71
View as plain text