fix: fixed the bug that old trace instances may be fetched

This commit is contained in:
chenquan
2023-02-22 17:21:58 +08:00
committed by Kevin Wan
parent 133c40ac1c
commit 3bc40d9eaf
6 changed files with 77 additions and 12 deletions

View File

@@ -5,7 +5,6 @@ import (
"database/sql"
"github.com/zeromicro/go-zero/core/trace"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
oteltrace "go.opentelemetry.io/otel/trace"
@@ -14,7 +13,8 @@ import (
var sqlAttributeKey = attribute.Key("sql.method")
func startSpan(ctx context.Context, method string) (context.Context, oteltrace.Span) {
tracer := otel.Tracer(trace.TraceName)
tracer := trace.TracerFromContext(ctx)
start, span := tracer.Start(ctx,
spanName,
oteltrace.WithSpanKind(oteltrace.SpanKindClient),