imaffe commented on a change in pull request #18674:
URL: https://github.com/apache/flink/pull/18674#discussion_r802321257



##########
File path: 
flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/sink/writer/PulsarWriter.java
##########
@@ -143,11 +152,15 @@ public void write(IN element, Context context) throws 
IOException, InterruptedEx
         } else {
             // Waiting for permits to write message.
             pendingMessages.acquire();
+            long sendStartTime = timeService.getCurrentProcessingTime();
             CompletableFuture<MessageId> sender = builder.sendAsync();
             sender.whenComplete(
                     (id, ex) -> {
+                        long sendEndTime = 
timeService.getCurrentProcessingTime();
+                        this.lastSendTime = sendEndTime - sendStartTime;

Review comment:
       update to lastSendTime should be thread-safe ?

##########
File path: 
flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/sink/writer/topic/TopicProducerRegister.java
##########
@@ -189,4 +198,16 @@ private void clearTransactions() {
         // Clear the transactions, we would create new transaction when new 
message comes.
         transactionRegister.clear();
     }
+
+    /** Retrieve the producer metrics and map to Flink SinkWriterMetrics. */
+    private void updateProducerStats() {
+        long numBytesOutSum = 0;
+        long numRecordsOutSum = 0;
+        for (Producer<?> producer : producerRegister.values()) {
+            numBytesOutSum += producer.getStats().getNumBytesSent();
+            numRecordsOutSum += producer.getStats().getNumMsgsSent();

Review comment:
       recordsOut can be collected on sendAsync() callback complete, but I 
think current implementation is ok ~




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to