Skip to content

Commit

Permalink
fix as commented: use embedding to get rid of delegations
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <sandor.szuecs@zalando.de>
  • Loading branch information
szuecs committed Nov 30, 2022
1 parent 844e746 commit 8e16270
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions tracing/tracers/basic/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type CloseableTracer interface {
}

type basicTracer struct {
tracer opentracing.Tracer
quit chan struct{}
once sync.Once
opentracing.Tracer
quit chan struct{}
once sync.Once
}

func InitTracer(opts []string) (CloseableTracer, error) {
Expand Down Expand Up @@ -71,14 +71,14 @@ func InitTracer(opts []string) (CloseableTracer, error) {

quit := make(chan struct{})
bt := &basicTracer{
tracer: basic.NewWithOptions(basic.Options{
basic.NewWithOptions(basic.Options{
DropAllLogs: dropAllLogs,
ShouldSample: func(traceID uint64) bool { return traceID%sampleModulo == 0 },
MaxLogsPerSpan: maxLogsPerSpan,
Recorder: recorder,
}),
quit: quit,
once: sync.Once{},
quit,
sync.Once{},
}

go func() {
Expand Down Expand Up @@ -111,18 +111,6 @@ func invalidArg(opt string, err error) error {
return fmt.Errorf("invalid argument for %s option: %s", opt, err)
}

func (bt *basicTracer) StartSpan(operationName string, opts ...opentracing.StartSpanOption) opentracing.Span {
return bt.tracer.StartSpan(operationName, opts...)
}

func (bt *basicTracer) Inject(sm opentracing.SpanContext, format interface{}, carrier interface{}) error {
return bt.tracer.Inject(sm, format, carrier)
}

func (bt *basicTracer) Extract(format interface{}, carrier interface{}) (opentracing.SpanContext, error) {
return bt.tracer.Extract(format, carrier)
}

func (bt *basicTracer) Close() {
bt.once.Do(func() {
close(bt.quit)
Expand Down

0 comments on commit 8e16270

Please sign in to comment.