From f843d50f849c5014eba33d923085f0add41365a6 Mon Sep 17 00:00:00 2001 From: Duong Cong Toai <35887761+duongcongtoai@users.noreply.github.com> Date: Tue, 3 Dec 2024 19:01:04 +0100 Subject: [PATCH] fix(pubsub): only init batch span if trace enabled (#11193) Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com> --- pubsub/topic.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pubsub/topic.go b/pubsub/topic.go index bb916f529056..72d9a3459035 100644 --- a/pubsub/topic.go +++ b/pubsub/topic.go @@ -993,8 +993,6 @@ func (t *Topic) Publish(ctx context.Context, msg *Message) *PublishResult { fcSpan.End() } - _, batcherSpan = startSpan(ctx, batcherSpanName, "") - bmsg := &bundledMessage{ msg: msg, res: r, @@ -1003,6 +1001,7 @@ func (t *Topic) Publish(ctx context.Context, msg *Message) *PublishResult { } if t.enableTracing { + _, batcherSpan = startSpan(ctx, batcherSpanName, "") bmsg.batcherSpan = batcherSpan // Inject the context from the first publish span rather than from flow control / batching.