Skip to content

Commit

Permalink
fix(pubsub): fix defer call in for loop (googleapis#11175)
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
Co-authored-by: Alex Hong <9397363+hongalex@users.noreply.github.com>
  • Loading branch information
zchee and hongalex authored Dec 6, 2024
1 parent 40cf125 commit 7aec711
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pubsub/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,15 @@ func (t *Topic) initBundler() {
for _, m := range bmsgs {
m.batcherSpan.End()
m.createSpan.AddEvent(eventPublishStart, trace.WithAttributes(semconv.MessagingBatchMessageCount(len(bmsgs))))
defer m.createSpan.End()
defer m.createSpan.AddEvent(eventPublishEnd)
}
}
t.publishMessageBundle(ctx, bmsgs)
if t.enableTracing {
for _, m := range bmsgs {
m.createSpan.AddEvent(eventPublishEnd)
m.createSpan.End()
}
}
})
t.scheduler.DelayThreshold = t.PublishSettings.DelayThreshold
t.scheduler.BundleCountThreshold = t.PublishSettings.CountThreshold
Expand Down

0 comments on commit 7aec711

Please sign in to comment.