You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

20 lines
403 B

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
}