[ 
https://issues.apache.org/jira/browse/GOBBLIN-1989?focusedWorklogId=901105&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-901105
 ]

ASF GitHub Bot logged work on GOBBLIN-1989:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Jan/24 03:57
            Start Date: 23/Jan/24 03:57
    Worklog Time Spent: 10m 
      Work Description: phet commented on code in PR #3843:
URL: https://github.com/apache/gobblin/pull/3843#discussion_r1462687175


##########
gobblin-temporal/src/main/java/org/apache/gobblin/temporal/workflows/metrics/TrackingEventMetadata.java:
##########
@@ -0,0 +1,73 @@
+package org.apache.gobblin.temporal.workflows.metrics;
+
+import java.util.List;
+
+import com.codahale.metrics.Gauge;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.Getter;
+
+import org.apache.gobblin.configuration.State;
+import org.apache.gobblin.instrumented.Instrumented;
+import org.apache.gobblin.metrics.MetricContext;
+import org.apache.gobblin.metrics.Tag;
+import org.apache.gobblin.metrics.event.EventSubmitter;
+
+import static org.apache.gobblin.instrumented.GobblinMetricsKeys.CLASS_META;
+
+
+/**
+ * Package private impl for sending the core essence of an {@link 
EventSubmitter} over the wire
+ *
+ * TODO: Fix this description
+ *
+ * Serializer for jackson that does its best to serialize a {@link 
EventSubmitter} from a json representation.
+ * NOTE: Due to the nested bidirectional nature of the {@link 
org.apache.gobblin.metrics.InnerMetricContext} and
+ * usage of {@link Gauge} this is not a perfect serialization but it is 
sufficient for passing important monitoring
+ * like original Azkaban flow name and gobblin job id
+ */
+@Getter
+public class TrackingEventMetadata {
+  private final List<Tag<?>> tags;
+  private final String namespace;
+  private final Class callerClass;
+
+  @JsonCreator
+  private TrackingEventMetadata(
+      @JsonProperty("tags") List<Tag<?>> tags,
+      @JsonProperty("namespace") String namespace,
+      @JsonProperty("callerClass") Class callerClass) {
+    this.tags = tags;
+    this.namespace = namespace;
+    this.callerClass = callerClass;
+  }
+
+  public TrackingEventMetadata(List<Tag<?>> tags, String namespace) {
+    // Explicitly send class over the wire to avoid any classloader issues
+    this(tags, namespace, tags.stream()
+        .filter(tag -> tag.getKey().equals(CLASS_META))
+        .findAny()
+        .map(tag -> (String) tag.getValue())
+        .map(TrackingEventMetadata::resolveClass)
+        .orElse(TrackingEventMetadata.class));
+  }
+
+  public TrackingEventMetadata(EventSubmitter eventSubmitter) {
+    this(eventSubmitter.getTags(), eventSubmitter.getNamespace());
+  }
+
+  public EventSubmitter createEventSubmitter() {
+    MetricContext metricContext = Instrumented.getMetricContext(new State(), 
callerClass, tags);
+    return new EventSubmitter.Builder(metricContext, namespace).build();
+  }

Review Comment:
   on the one hand, I like the encapsulation of magically turning one's TEM 
into an `EventSubmitter`... but it seems unintuitive and not memorable that 
"metadata" should double as an `EventSubmitter` factory.
   
   I believe this is more a matter of naming than of an abstraction that's not 
cohesive and trying to do too many things.  what's your take?
   
   (perhaps the hang up for me is that events themselves contain metadata, such 
as the timing info you add to `EventBuilder`... but AFAICT this is NOT related 
to the extensible set of metadata that a particular activity might use to 
specify an event.)





Issue Time Tracking
-------------------

    Worklog Id:     (was: 901105)
    Time Spent: 1h 10m  (was: 1h)

> TemporaI: Implementation of GTE for GaaS Observability Event in MR 
> deprecation for distcp
> -----------------------------------------------------------------------------------------
>
>                 Key: GOBBLIN-1989
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1989
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Matthew Ho
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to