package trace import ( "context" "fmt" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/trace" ) func TracerFromContext(ctx context.Context) (tracer trace.Tracer) { if span := trace.SpanFromContext(ctx); span.SpanContext().IsValid() { fmt.Println("find") tracer = span.TracerProvider().Tracer(TraceName) } else { fmt.Println("not find") tracer = otel.Tracer(TraceName) } return }