gianm commented on a change in pull request #6493: Support for request logging 
in kafka emitter.
URL: https://github.com/apache/incubator-druid/pull/6493#discussion_r236850395
 
 

 ##########
 File path: 
extensions-contrib/kafka-emitter/src/main/java/org/apache/druid/emitter/kafka/KafkaEmitter.java
 ##########
 @@ -156,14 +174,16 @@ private void sendToKafka(final String topic, 
MemoryBoundLinkedBlockingQueue<Stri
   public void emit(final Event event)
   {
     if (event != null) {
-      ImmutableMap.Builder<String, Object> resultBuilder = 
ImmutableMap.<String, Object>builder().putAll(event.toMap());
 
 Review comment:
   This code should work too, and is simpler:
   
   ```java
       // Avoid toMap() since it isn't universally supported (e.g. 
RequestLogEvent). 
       final Map<String, Object> eventMap = jsonMapper.convertValue(event, 
JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT);
       if (config.getClusterName() != null) {
         resultBuilder.put("clusterName", config.getClusterName());
       }
   ```
   
   It takes advantage of the fact that the Jackson annotations should always 
"work" on Event types.
   
   Separately, maybe we should remove toMap from the Event class, or at least 
deprecate it… it doesn't seem generally useful due to the fact that it doesn't 
work for all Event types. (And it isn't commonly used either: only KafkaEmitter 
and ParametrizedUriEmitter use it, today.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to