lukecwik commented on a change in pull request #12984:
URL: https://github.com/apache/beam/pull/12984#discussion_r501948250



##########
File path: 
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/HotKeyLoggerTest.java
##########
@@ -50,11 +50,11 @@ public void SetUp() {
   }
 
   @Test
-  public void correctHotKeyMessage() {
+  public void correctHotKeyMessageWithoutKey() {
     HotKeyLogger hotKeyLogger = new HotKeyLogger(clock);
 
     assertFalse(hotKeyLogger.isThrottled());
-    String m = hotKeyLogger.getHotKeyMessage("TEST_STEP_ID", "1s");
+    String m = hotKeyLogger.getHotKeyMessage("TEST_STEP_ID", "1s", null);

Review comment:
       You can use ExpectedLogs as a test rule to capture whether output was 
produced or not instead of abstracting out a getHotKeyMessage. See 
https://github.com/apache/beam/blob/cfca7f176acb3542c7b86312f968819a1e97866e/sdks/java/core/src/test/java/org/apache/beam/sdk/coders/SerializableCoderTest.java#L259
 for an example.

##########
File path: 
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/HotKeyLogger.java
##########
@@ -67,11 +72,19 @@ protected boolean isThrottled() {
     return false;
   }
 
-  protected String getHotKeyMessage(String userStepName, String hotKeyAge) {
+  protected String getHotKeyMessage(String userStepName, String hotKeyAge, 
Object hotkey) {
+    if (hotkey == null) {
+      return MessageFormat.format(

Review comment:
       you should rely on slf4j for log formatting with parameters as we won't 
pay the cost of forming the string if logging is disabled. e.g.:
   ```LOG.warn("my message with param 1 {}, param 2 {}", param1, param2);```




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

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


Reply via email to