Skip to content

Commit

Permalink
Refactor provider.go
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed May 14, 2021
1 parent 188501d commit d6ef32c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sdk/trace/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ func WithBatcher(e SpanExporter, opts ...BatchSpanProcessorOption) TracerProvide

// WithSpanProcessor registers the SpanProcessor with a TracerProvider.
func WithSpanProcessor(sp SpanProcessor) TracerProviderOption {
return traceProviderOptionFunc(func(opts *tracerProviderConfig) {
opts.processors = append(opts.processors, sp)
return traceProviderOptionFunc(func(cfg *tracerProviderConfig) {
cfg.processors = append(cfg.processors, sp)
})
}

Expand All @@ -277,8 +277,8 @@ func WithSpanProcessor(sp SpanProcessor) TracerProviderOption {
// If this option is not used, the TracerProvider will use the
// resource.Default() Resource by default.
func WithResource(r *resource.Resource) TracerProviderOption {
return traceProviderOptionFunc(func(opts *tracerProviderConfig) {
opts.resource = resource.Merge(resource.Environment(), r)
return traceProviderOptionFunc(func(cfg *tracerProviderConfig) {
cfg.resource = resource.Merge(resource.Environment(), r)
})
}

Expand All @@ -290,9 +290,9 @@ func WithResource(r *resource.Resource) TracerProviderOption {
// If this option is not used, the TracerProvider will use a random number
// IDGenerator by default.
func WithIDGenerator(g IDGenerator) TracerProviderOption {
return traceProviderOptionFunc(func(opts *tracerProviderConfig) {
return traceProviderOptionFunc(func(cfg *tracerProviderConfig) {
if g != nil {
opts.idGenerator = g
cfg.idGenerator = g
}
})
}
Expand All @@ -305,9 +305,9 @@ func WithIDGenerator(g IDGenerator) TracerProviderOption {
// If this option is not used, the TracerProvider will use a
// ParentBased(AlwaysSample) Sampler by default.
func WithSampler(s Sampler) TracerProviderOption {
return traceProviderOptionFunc(func(opts *tracerProviderConfig) {
return traceProviderOptionFunc(func(cfg *tracerProviderConfig) {
if s != nil {
opts.sampler = s
cfg.sampler = s
}
})
}
Expand All @@ -320,8 +320,8 @@ func WithSampler(s Sampler) TracerProviderOption {
// If this option is not used, the TracerProvider will use the default
// SpanLimits.
func WithSpanLimits(sl SpanLimits) TracerProviderOption {
return traceProviderOptionFunc(func(opts *tracerProviderConfig) {
opts.spanLimits = sl
return traceProviderOptionFunc(func(cfg *tracerProviderConfig) {
cfg.spanLimits = sl
})
}

Expand Down

0 comments on commit d6ef32c

Please sign in to comment.