From 2c21cce07679a28fe31b77445fde70c25994d206 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 5 May 2025 09:48:22 +0300 Subject: [PATCH] tracer/noop: disable allocation for trace and span id Signed-off-by: Vasiliy Tolstov --- tracer/noop.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tracer/noop.go b/tracer/noop.go index 80de5fc0..d76a5887 100644 --- a/tracer/noop.go +++ b/tracer/noop.go @@ -4,7 +4,7 @@ import ( "context" "time" - "go.unistack.org/micro/v4/util/id" + "github.com/google/uuid" ) var _ Tracer = (*noopTracer)(nil) @@ -18,6 +18,8 @@ func (t *noopTracer) Spans() []Span { return t.spans } +var uuidNil = uuid.Nil.String() + func (t *noopTracer) Start(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) { options := NewSpanOptions(opts...) span := &noopSpan{ @@ -28,8 +30,8 @@ func (t *noopTracer) Start(ctx context.Context, name string, opts ...SpanOption) labels: options.Labels, kind: options.Kind, } - span.spanID.s, _ = id.New() - span.traceID.s, _ = id.New() + span.spanID.s = uuidNil + span.traceID.s = uuidNil if span.ctx == nil { span.ctx = context.Background() }