[#34] tracing: use atomic.Pointer

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
feature/40-autogen_marsh/refs_grpc
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...)
}