diff --git a/config/config.go b/config/config.go index 165754b2..26b461d2 100644 --- a/config/config.go +++ b/config/config.go @@ -277,6 +277,10 @@ func (c Configuration) NewTracer(options ...Option) (opentracing.Tracer, io.Clos tracerOptions = append(tracerOptions, jaeger.TracerOptions.Gen128Bit(true)) } + if opts.randomNumber != nil { + tracerOptions = append(tracerOptions, jaeger.TracerOptions.RandomNumber(opts.randomNumber)) + } + for _, tag := range opts.tags { tracerOptions = append(tracerOptions, jaeger.TracerOptions.Tag(tag.Key, tag.Value)) } diff --git a/config/options.go b/config/options.go index e0e50e83..27c23777 100644 --- a/config/options.go +++ b/config/options.go @@ -40,6 +40,7 @@ type Options struct { tags []opentracing.Tag injectors map[interface{}]jaeger.Injector extractors map[interface{}]jaeger.Extractor + randomNumber func() uint64 } // Metrics creates an Option that initializes Metrics in the tracer, @@ -147,6 +148,13 @@ func Extractor(format interface{}, extractor jaeger.Extractor) Option { } } +// WithRandonNunmber set the Tracer random number func +func WithRandonNunmber(f func() uint64) Option { + return func(c *Options) { + c.randomNumber = f + } +} + func applyOptions(options ...Option) Options { opts := Options{ injectors: make(map[interface{}]jaeger.Injector),