From 5f148632d281bcfe6bd2acf75a65441210c573f9 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 12 Apr 2023 10:35:24 +0800 Subject: [PATCH] fix missing trace id in gctx.GetInitCtx (#2562) --- example/trace/processes/gcmd/main.go | 2 +- example/trace/processes/gcmd/sub/sub.go | 2 +- example/trace/processes/gproc/main.go | 2 +- example/trace/processes/gproc/sub/sub.go | 2 +- os/gctx/gctx.go | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/example/trace/processes/gcmd/main.go b/example/trace/processes/gcmd/main.go index 8015a2e08..4f24898e6 100644 --- a/example/trace/processes/gcmd/main.go +++ b/example/trace/processes/gcmd/main.go @@ -21,5 +21,5 @@ var ( ) func main() { - Main.Run(gctx.New()) + Main.Run(gctx.GetInitCtx()) } diff --git a/example/trace/processes/gcmd/sub/sub.go b/example/trace/processes/gcmd/sub/sub.go index 2e546a8a4..69f451e70 100644 --- a/example/trace/processes/gcmd/sub/sub.go +++ b/example/trace/processes/gcmd/sub/sub.go @@ -20,5 +20,5 @@ var ( ) func main() { - Sub.Run(gctx.New()) + Sub.Run(gctx.GetInitCtx()) } diff --git a/example/trace/processes/gproc/main.go b/example/trace/processes/gproc/main.go index 50c701a9d..ba334cfa0 100644 --- a/example/trace/processes/gproc/main.go +++ b/example/trace/processes/gproc/main.go @@ -7,7 +7,7 @@ import ( ) func main() { - ctx := gctx.New() + ctx := gctx.GetInitCtx() g.Log().Debug(ctx, `this is main process`) if err := gproc.ShellRun(ctx, `go run sub/sub.go`); err != nil { panic(err) diff --git a/example/trace/processes/gproc/sub/sub.go b/example/trace/processes/gproc/sub/sub.go index 8a743de16..cd0238a87 100644 --- a/example/trace/processes/gproc/sub/sub.go +++ b/example/trace/processes/gproc/sub/sub.go @@ -6,6 +6,6 @@ import ( ) func main() { - ctx := gctx.New() + ctx := gctx.GetInitCtx() g.Log().Debug(ctx, `this is sub process`) } diff --git a/os/gctx/gctx.go b/os/gctx/gctx.go index 62032b362..d6f05cc34 100644 --- a/os/gctx/gctx.go +++ b/os/gctx/gctx.go @@ -44,6 +44,7 @@ func init() { context.Background(), propagation.MapCarrier(m), ) + initCtx = WithCtx(initCtx) } // New creates and returns a context which contains context id.