mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 12:17:53 +08:00
rename SetTraceID to WithTraceID for package gtrace
This commit is contained in:
parent
b6d60fc209
commit
f583f28953
@ -144,14 +144,14 @@ func GetBaggageVar(ctx context.Context, key string) *gvar.Var {
|
||||
return NewBaggage(ctx).GetVar(key)
|
||||
}
|
||||
|
||||
// SetTraceID injects custom trace id into context to propagate.
|
||||
func SetTraceID(ctx context.Context, traceID trace.TraceID) context.Context {
|
||||
// WithTraceID injects custom trace id into context to propagate.
|
||||
func WithTraceID(ctx context.Context, traceID trace.TraceID) context.Context {
|
||||
sc := trace.SpanContextFromContext(ctx)
|
||||
if !sc.HasTraceID() {
|
||||
var (
|
||||
span trace.Span
|
||||
)
|
||||
ctx, span = NewSpan(ctx, "gtrace.SetTraceID")
|
||||
ctx, span = NewSpan(ctx, "gtrace.WithTraceID")
|
||||
defer span.End()
|
||||
sc = trace.SpanContextFromContext(ctx)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ func Test_Client_Server_Tracing(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_SetTraceID(t *testing.T) {
|
||||
func Test_WithTraceID(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
p := 8889
|
||||
s := g.Server(p)
|
||||
@ -61,7 +61,7 @@ func Test_SetTraceID(t *testing.T) {
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
ctx := gtrace.SetTraceID(context.TODO(), traceID)
|
||||
ctx := gtrace.WithTraceID(context.TODO(), traceID)
|
||||
|
||||
prefix := fmt.Sprintf("http://127.0.0.1:%d", p)
|
||||
client := g.Client()
|
||||
|
Loading…
Reference in New Issue
Block a user