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.
```
@Data
@Builder
@Builder
@Jacksonized
@Jacksonized
public class EventSubmitterPojoWrapper {
public class EventSubmitterAsPojo {
Class callerClazz;
Class callerClazz;
String namespace;
String namespace;
State state;
State state;
List<Tag<?>> tags;
List<Tag<?>> tags;
@JsonIgnore
@JsonIgnore
public EventSubmitter get() {
public EventSubmitter get() {
// NOTE: This metric context is constructed differently from the
AbstractJobLauncher, which uses JobMetrics.get() instead
// NOTE: This metric context is constructed differently from the
AbstractJobLauncher, which uses JobMetrics.get() instead
MetricContext metricContext = Instrumented.getMetricContext(state,
callerClazz, tags);
MetricContext metricContext = Instrumented.getMetricContext(state,
callerClazz, tags);
return new EventSubmitter.Builder(metricContext, namespace).build();
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]