mynameborat commented on a change in pull request #1474:
URL: https://github.com/apache/samza/pull/1474#discussion_r592682743



##########
File path: 
samza-log4j2/src/main/java/org/apache/samza/logging/log4j2/StreamAppender.java
##########
@@ -75,16 +75,16 @@
 
   private static final String JAVA_OPTS_CONTAINER_NAME = 
"samza.container.name";
   private static final String JOB_COORDINATOR_TAG = "samza-job-coordinator";
-  private static final String SOURCE = "log4j-log";
+  protected static final String SOURCE = "log4j-log";
 
   // Hidden config for now. Will move to appropriate Config class when ready 
to.
   private static final String CREATE_STREAM_ENABLED = 
"task.log4j.create.stream.enabled";
 
   private static final long DEFAULT_QUEUE_TIMEOUT_S = 2; // Abitrary choice
   private final BlockingQueue<byte[]> logQueue = new 
LinkedBlockingQueue<>(DEFAULT_QUEUE_SIZE);
 
-  private SystemStream systemStream = null;
-  private SystemProducer systemProducer = null;
+  protected SystemStream systemStream = null;
+  protected SystemProducer systemProducer = null;

Review comment:
       It looks like you need some sort of decorator around the actual log 
events that gets sent to the underlying producer. The decorator will take in a 
`serializedLogEvent` as `byte[]` and returns an `OutgoingMessageEnvelope` which 
the extenders can choose to override however they want.
   
   For e.g
   
   ```
   // default implementation
   protected OutgoingMessageEnvelope decorateLogEvent(byte[] 
serializedLogEvent) {
      return new OutgoingMessageEnvelope(systemStream, keyBytes, 
serializedLogEvent);
   }
   
   private void sendEventToSystemProducer(byte[] serializedLogEvent {
     metrics.logMessagesBytesSent.inc(serializedLogEvent.length);
     metrics.logMessagesCountSent.inc();
     systemProducer.send(SOURCE, decorateLogEvent(serializedLogEvent));
   }
   ```




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