homatthew commented on code in PR #3843:
URL: https://github.com/apache/gobblin/pull/3843#discussion_r1416349108


##########
gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/EventSubmitter.java:
##########
@@ -37,6 +53,8 @@
  * </p>
  *
  */
+@JsonSerialize(using = EventSubmitter.Serializer.class)
+@JsonDeserialize(using = EventSubmitter.Deserializer.class)

Review Comment:
   I considered 2 approaches:
   1. Jackson native serializer / deserializer via annotations
   2. A wrapper object that contains the core essence of what is an 
"eventSubmitter"
   
   e.g.
   ```
   /**
    * A POJO that can be used to serialize and deserialize an {@link 
EventSubmitter} for use in a {@link io.temporal.workflow.Workflow}
    */
   @Data
   @Builder
   @Jacksonized
   public class EventSubmitterAsPojo {
     Class callerClazz;
     String namespace;
     State state;
     List<Tag<?>> tags;
   
     @JsonIgnore
     public EventSubmitter get() {
       // NOTE: This metric context is constructed differently from the 
AbstractJobLauncher, which uses JobMetrics.get() instead
       MetricContext metricContext = Instrumented.getMetricContext(state, 
callerClazz, tags);
       return new EventSubmitter.Builder(metricContext, namespace).build();
     }
   }
   ```
   
   This works okay given that it makes it very obvious that we cannot truly 
serialize an EventSubmitter, so we are trying our best to represent it as a 
POJO. But the downside is that it adds a lot of boiler plate for something that 
I'd imagine will be used pretty often.
   
   The downside of using the native Serialize / Deserialize in Jackson is that 
the Serializer / Deserializer must live in the same Gradle module as the 
EventSubmitter (`gobblin.metrics`). But as a result, we cannot natively use 
Instrumented.getMetricContext or JobMetrics.get like in the AbstractJobLauncher 
or GobblinOrcWriter.
   
   Instead, we need a separate impl of creating the metric context, which 
closely mirrors the way `Instrumented.getMetricContext`. 



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