From 9f6620676afe778fa79daaaacc79e2bb522b9282 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Wed, 17 Jul 2024 17:51:51 +0300 Subject: [PATCH] get trace info from context Signed-off-by: Vasiliy Tolstov --- opentracing.go | 6 ++++++ opentracing_test.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/opentracing.go b/opentracing.go index 587ce69..4ebc04f 100644 --- a/opentracing.go +++ b/opentracing.go @@ -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)) for k, v := range carrier { switch k { + case "mockpfx-ids-sampled": + continue + case "mockpfx-ids-spanid": + spanID = v + case "mockpfx-ids-traceid": + traceID = v default: // reasonable default p := strings.Split(v, ":") traceID = p[0] diff --git a/opentracing_test.go b/opentracing_test.go index 0b0ce05..cd5d6b8 100644 --- a/opentracing_test.go +++ b/opentracing_test.go @@ -86,7 +86,7 @@ func TestRealTraceID(t *testing.T) { } l.Info(ctx, "msg") } -* +*/ func TestTraceTags(t *testing.T) { md := metadata.New(1)