Skip to content

Commit 7aec711

Browse files
zcheehongalex
andauthored
fix(pubsub): fix defer call in for loop (#11175)
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com> Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com>
1 parent 40cf125 commit 7aec711

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pubsub/topic.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,15 @@ func (t *Topic) initBundler() {
10861086
for _, m := range bmsgs {
10871087
m.batcherSpan.End()
10881088
m.createSpan.AddEvent(eventPublishStart, trace.WithAttributes(semconv.MessagingBatchMessageCount(len(bmsgs))))
1089-
defer m.createSpan.End()
1090-
defer m.createSpan.AddEvent(eventPublishEnd)
10911089
}
10921090
}
10931091
t.publishMessageBundle(ctx, bmsgs)
1092+
if t.enableTracing {
1093+
for _, m := range bmsgs {
1094+
m.createSpan.AddEvent(eventPublishEnd)
1095+
m.createSpan.End()
1096+
}
1097+
}
10941098
})
10951099
t.scheduler.DelayThreshold = t.PublishSettings.DelayThreshold
10961100
t.scheduler.BundleCountThreshold = t.PublishSettings.CountThreshold

0 commit comments

Comments
 (0)