ethqunzhong commented on code in PR #20366:
URL: https://github.com/apache/pulsar/pull/20366#discussion_r1209236179


##########
tiered-storage/file-system/src/main/java/org/apache/bookkeeper/mledger/offload/filesystem/impl/FileSystemManagedLedgerOffloader.java:
##########
@@ -317,11 +320,11 @@ public void run() {
                         dataWriter.append(key, value);
                     } catch (IOException e) {
                         ledgerReader.fileSystemWriteException = e;
-                        
ledgerReader.offloaderStats.recordWriteToStorageError(managedLedgerName);
+                        
ledgerReader.offloaderStats.recordWriteToStorageError(topicName);
                         break;
                     }
                     haveOffloadEntryNumber.incrementAndGet();
-                    
ledgerReader.offloaderStats.recordOffloadBytes(managedLedgerName, 
entry.getLength());
+                    ledgerReader.offloaderStats.recordOffloadBytes(topicName, 
entry.getEntryBytes().length);

Review Comment:
   <img width="971" alt="image" 
src="https://github.com/apache/pulsar/assets/16517186/f0b91ead-dac5-450a-9f31-a86b0f54b7da";>
   From the perspective of entry implementation, using entry.getLength() to 
record metrics will result in duplicated calculations of data.
   
   ```
   while (iterator.hasNext()) {  
        LedgerEntry entry = iterator.next();
        ...
       ledgerReader.offloaderStats.recordOffloadBytes(topicName, 
entry.getLength());  
   }
   ```
   
   This will cause the metrics to be much larger than the actual values.
   To reduce expensive calls, I made the following adjustments. Please help me 
review them again.
   
   ```
   while (iterator.hasNext()) {  
       int currentEntrySize;  
       try {  
           currentEntrySize = entry.getEntryBytes().length;  
                ...
       } catch (IOException e) {  
            ...
           break;  
       }  
       haveOffloadEntryNumber.incrementAndGet();  
       ledgerReader.offloaderStats.recordOffloadBytes(topicName, 
currentEntrySize);  
   }
   ```
   



-- 
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