Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Move message timer around (#9)
Browse files Browse the repository at this point in the history
In batch writes, this would produce histogram timers in seconds, since
the counter would to wait for all several thousand messages to be sent.
  • Loading branch information
vjanelle authored and afalko committed Apr 30, 2018
1 parent 55e4491 commit 9e45546
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/com/salesforce/WriteTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public Exception call() {


while (keepProducing) {
produceMessageTimeSecs.time(() -> {
// TODO: Get this from properties
for (int i = 0; i < numMessagesToSendPerBatch; i++) {
kafkaProducer.send(new ProducerRecord<>(topicName, topicId, i));
log.debug("{}: Produced message {}", formatter.format(new Date()), topicId);
}
});
// TODO: Get this from properties
for (int i = 0; i < numMessagesToSendPerBatch; i++) {
Histogram.Timer requestTimer = produceMessageTimeSecs.startTimer();
kafkaProducer.send(new ProducerRecord<>(topicName, topicId, i));
requestTimer.observeDuration();
log.debug("{}: Produced message {}", formatter.format(new Date()), topicId);
}
threadsAwaitingMessageProduce.dec();
Thread.sleep(readWriteInterval);
threadsAwaitingMessageProduce.inc();
Expand Down

0 comments on commit 9e45546

Please sign in to comment.