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

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

                Author: ASF GitHub Bot
            Created on: 27/Jun/19 21:28
            Start Date: 27/Jun/19 21:28
    Worklog Time Spent: 10m 
      Work Description: ibuenros commented on pull request #2678: [GOBBLIN-807] 
TimingEvent is now closeable, extends GobblinEventBuilder
URL: https://github.com/apache/incubator-gobblin/pull/2678#discussion_r298376096
 
 

 ##########
 File path: 
gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/CountEventBuilder.java
 ##########
 @@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.metrics.event;
+
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import org.apache.gobblin.metrics.GobblinTrackingEvent;
+
+/**
+ * The builder builds builds a specific {@link GobblinTrackingEvent} whose 
metadata has
+ * {@value GobblinEventBuilder#EVENT_TYPE} to be {@value #COUNT_EVENT_TYPE}
+ *
+ * <p>
+ * Note: A {@link CountEventBuilder} instance is not reusable
+ */
+public class CountEventBuilder extends GobblinEventBuilder {
+
+  public static final String COUNT_EVENT_TYPE = "CountEvent";
+  public static final String COUNT_KEY = "count";
+  @Setter
+  @Getter
+  private int count;
+
+  public CountEventBuilder(String name) {
+    this(name, NAMESPACE);
+  }
+
+  public CountEventBuilder(String name, String namespace) {
+    super(name, namespace);
+    this.metadata.put(EVENT_TYPE, COUNT_EVENT_TYPE);
+  }
+
+  /**
+   *
+   * @return {@link GobblinTrackingEvent}
+   */
+  @Override
+  public GobblinTrackingEvent build() {
+    this.metadata.put(COUNT_KEY, Integer.toString(count));
 
 Review comment:
   As implemented right now, it is easy for the user to forget to set the 
count. Most mandatory values should be set either in the constructor or `build`.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 268850)
    Time Spent: 2.5h  (was: 2h 20m)

> TimingEvent to extend GobblinEventBuilder 
> ------------------------------------------
>
>                 Key: GOBBLIN-807
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-807
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Vikram Bohra
>            Priority: Minor
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> GobblinEventBuilder and its subclasses should be used to build 
> GobblinTrackingEvents and EventSubmitter should solely be responsible for 
> submitting events. Depreacate older roles and methods 
> appropriately.TimingEvent should extend the GobblinEventBuilder while 
> maintaining older methods for backward compatability.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to