@@ -24,6 +24,7 @@ import (
24
24
"go.opentelemetry.io/otel/api/global"
25
25
"go.opentelemetry.io/otel/api/kv"
26
26
"go.opentelemetry.io/otel/api/kv/value"
27
+ apitrace "go.opentelemetry.io/otel/api/trace"
27
28
gen "go.opentelemetry.io/otel/exporters/trace/jaeger/internal/gen-go/jaeger"
28
29
export "go.opentelemetry.io/otel/sdk/export/trace"
29
30
sdktrace "go.opentelemetry.io/otel/sdk/trace"
@@ -38,7 +39,7 @@ type options struct {
38
39
// Process contains the information about the exporting process.
39
40
Process Process
40
41
41
- //BufferMaxCount defines the total number of traces that can be buffered in memory
42
+ // BufferMaxCount defines the total number of traces that can be buffered in memory
42
43
BufferMaxCount int
43
44
44
45
Config * sdktrace.Config
@@ -57,7 +58,7 @@ func WithProcess(process Process) Option {
57
58
}
58
59
}
59
60
60
- //WithBufferMaxCount defines the total number of traces that can be buffered in memory
61
+ // WithBufferMaxCount defines the total number of traces that can be buffered in memory
61
62
func WithBufferMaxCount (bufferMaxCount int ) Option {
62
63
return func (o * options ) {
63
64
o .BufferMaxCount = bufferMaxCount
@@ -87,22 +88,19 @@ func WithDisabled(disabled bool) Option {
87
88
88
89
// NewRawExporter returns a trace.Exporter implementation that exports
89
90
// the collected spans to Jaeger.
91
+ //
92
+ // It will IGNORE Disabled option.
90
93
func NewRawExporter (endpointOption EndpointOption , opts ... Option ) (* Exporter , error ) {
94
+ uploader , err := endpointOption ()
95
+ if err != nil {
96
+ return nil , err
97
+ }
98
+
91
99
o := options {}
92
100
opts = append (opts , WithDisabledFromEnv (), WithProcessFromEnv ())
93
101
for _ , opt := range opts {
94
102
opt (& o )
95
103
}
96
- if o .Disabled {
97
- return & Exporter {
98
- o : o ,
99
- }, nil
100
- }
101
-
102
- uploader , err := endpointOption ()
103
- if err != nil {
104
- return nil , err
105
- }
106
104
107
105
service := o .Process .ServiceName
108
106
if service == "" {
@@ -142,7 +140,15 @@ func NewRawExporter(endpointOption EndpointOption, opts ...Option) (*Exporter, e
142
140
143
141
// NewExportPipeline sets up a complete export pipeline
144
142
// with the recommended setup for trace provider
145
- func NewExportPipeline (endpointOption EndpointOption , opts ... Option ) (* sdktrace.Provider , func (), error ) {
143
+ func NewExportPipeline (endpointOption EndpointOption , opts ... Option ) (apitrace.Provider , func (), error ) {
144
+ o := options {}
145
+ for _ , opt := range opts {
146
+ opt (& o )
147
+ }
148
+ if o .Disabled {
149
+ return & apitrace.NoopProvider {}, func () {}, nil
150
+ }
151
+
146
152
exporter , err := NewRawExporter (endpointOption , opts ... )
147
153
if err != nil {
148
154
return nil , nil , err
@@ -184,9 +190,6 @@ var _ export.SpanSyncer = (*Exporter)(nil)
184
190
185
191
// ExportSpan exports a SpanData to Jaeger.
186
192
func (e * Exporter ) ExportSpan (ctx context.Context , d * export.SpanData ) {
187
- if e .o .Disabled {
188
- return
189
- }
190
193
_ = e .bundler .Add (spanDataToThrift (d ), 1 )
191
194
// TODO(jbd): Handle oversized bundlers.
192
195
}
@@ -344,16 +347,10 @@ func getBoolTag(k string, b bool) *gen.Tag {
344
347
//
345
348
// This is useful if your program is ending and you do not want to lose recent spans.
346
349
func (e * Exporter ) Flush () {
347
- if e .o .Disabled {
348
- return
349
- }
350
350
e .bundler .Flush ()
351
351
}
352
352
353
353
func (e * Exporter ) upload (spans []* gen.Span ) error {
354
- if e .o .Disabled {
355
- return nil
356
- }
357
354
batch := & gen.Batch {
358
355
Spans : spans ,
359
356
Process : e .process ,
0 commit comments