improve tracing
Some checks failed
build / test (push) Failing after 26s
build / lint (push) Successful in 25s
codeql / analyze (go) (push) Failing after 49s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-07-22 23:39:22 +03:00
parent 9f6620676a
commit 89f75e0431

View File

@ -321,11 +321,15 @@ func (t *otTracer) startSpanFromOutgoingContext(ctx context.Context, name string
} }
nmd := metadata.Copy(md) nmd := metadata.Copy(md)
smd := metadata.New(1)
sp := t.tracer.StartSpan(name, opts...) sp := t.tracer.StartSpan(name, opts...)
if err := sp.Tracer().Inject(sp.Context(), ot.TextMap, ot.TextMapCarrier(nmd)); err != nil { if err := sp.Tracer().Inject(sp.Context(), ot.TextMap, ot.TextMapCarrier(smd)); err != nil {
return nil, nil return nil, nil
} }
for k, v := range smd {
nmd.Set(k, v)
}
ctx = metadata.NewOutgoingContext(ot.ContextWithSpan(ctx, sp), nmd) ctx = metadata.NewOutgoingContext(ot.ContextWithSpan(ctx, sp), nmd)
@ -364,11 +368,15 @@ func (t *otTracer) startSpanFromIncomingContext(ctx context.Context, name string
} }
nmd := metadata.Copy(md) nmd := metadata.Copy(md)
smd := metadata.New(1)
sp := t.tracer.StartSpan(name, opts...) sp := t.tracer.StartSpan(name, opts...)
if err := sp.Tracer().Inject(sp.Context(), ot.TextMap, ot.TextMapCarrier(nmd)); err != nil { if err := sp.Tracer().Inject(sp.Context(), ot.TextMap, ot.TextMapCarrier(smd)); err != nil {
return nil, nil return nil, nil
} }
for k, v := range smd {
nmd.Set(k, v)
}
ctx = metadata.NewIncomingContext(ot.ContextWithSpan(ctx, sp), nmd) ctx = metadata.NewIncomingContext(ot.ContextWithSpan(ctx, sp), nmd)