Skip to content

Commit

Permalink
fix(pubsub): fix defer call in for loop (#11175)
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <[email protected]>
Co-authored-by: Alex Hong <[email protected]>
  • 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.