[#34] tracing: use atomic.Pointer

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-05-19 14:40:17 +03:00
parent 33445c6810
commit 0c67b8fefa
2 changed files with 3 additions and 3 deletions

View file

@ -99,8 +99,8 @@ func Shutdown(ctx context.Context) error {
return flushAndShutdown(ctx)
}
func getDefaultTracer() *atomic.Value {
v := &atomic.Value{}
func getDefaultTracer() *atomic.Pointer[tracerHolder] {
v := new(atomic.Pointer[tracerHolder])
v.Store(&tracerHolder{Tracer: trace.NewNoopTracerProvider().Tracer("")})
return v
}

View file

@ -8,5 +8,5 @@ import (
// StartSpanFromContext creates a span and a context.Context containing the newly-created span.
func StartSpanFromContext(ctx context.Context, operationName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
return tracer.Load().(*tracerHolder).Tracer.Start(ctx, operationName, opts...)
return tracer.Load().Tracer.Start(ctx, operationName, opts...)
}