New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send kafka message in batch #1708
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,19 +155,15 @@ func (c *Collector) pushMetrics() { | |
|
||
// Send the samples | ||
c.logger.Debug("Kafka: Delivering...") | ||
|
||
|
||
var msgList []*sarama.ProducerMessage | ||
for _, sample := range formattedSamples { | ||
msg := &sarama.ProducerMessage{Topic: c.Config.Topic.String, Value: sarama.StringEncoder(sample)} | ||
partition, offset, err := c.Producer.SendMessage(msg) | ||
if err != nil { | ||
c.logger.WithError(err).Error("Kafka: failed to send message.") | ||
} else { | ||
c.logger.WithFields(logrus.Fields{ | ||
"partition": partition, | ||
"offset": offset, | ||
}).Debug("Kafka: message sent.") | ||
} | ||
msgList = append(msgList, msg) | ||
} | ||
// Send message in batch | ||
c.Producer.SendMessages(msgList) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is, what happens if this line somehow fails? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! Let me have a check. Thx @mostafa ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @RoySunnySean007 any movement on this change? |
||
|
||
|
||
t := time.Since(startTime) | ||
c.logger.WithField("t", t).Debug("Kafka: Delivered!") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to have logging while using
c.Producer.SendMessages(msgList)
on Line 165?