get trace info from context
Some checks failed
build / test (push) Failing after 23s
build / lint (push) Successful in 22s
codeql / analyze (go) (push) Failing after 1m0s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-07-17 17:51:51 +03:00
parent e1f85545d9
commit 9f6620676a
2 changed files with 7 additions and 1 deletions

View File

@ -88,6 +88,12 @@ func (t *otTracer) Start(ctx context.Context, name string, opts ...tracer.SpanOp
_ = span.Tracer().Inject(spctx, ot.TextMap, ot.TextMapCarrier(carrier)) _ = span.Tracer().Inject(spctx, ot.TextMap, ot.TextMapCarrier(carrier))
for k, v := range carrier { for k, v := range carrier {
switch k { switch k {
case "mockpfx-ids-sampled":
continue
case "mockpfx-ids-spanid":
spanID = v
case "mockpfx-ids-traceid":
traceID = v
default: // reasonable default default: // reasonable default
p := strings.Split(v, ":") p := strings.Split(v, ":")
traceID = p[0] traceID = p[0]

View File

@ -86,7 +86,7 @@ func TestRealTraceID(t *testing.T) {
} }
l.Info(ctx, "msg") l.Info(ctx, "msg")
} }
* */
func TestTraceTags(t *testing.T) { func TestTraceTags(t *testing.T) {
md := metadata.New(1) md := metadata.New(1)