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

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

                Author: ASF GitHub Bot
            Created on: 05/Nov/19 19:58
            Start Date: 05/Nov/19 19:58
    Worklog Time Spent: 10m 
      Work Description: autumnust commented on pull request #2795: GOBBLIN-945: 
Refactor Kafka extractor statistics tracking to allow co…
URL: https://github.com/apache/incubator-gobblin/pull/2795#discussion_r342768883
 
 

 ##########
 File path: 
gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/source/extractor/extract/kafka/KafkaExtractorStatsTracker.java
 ##########
 @@ -0,0 +1,320 @@
+/*
+ * 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.source.extractor.extract.kafka;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import lombok.Data;
+import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
+
+import org.apache.gobblin.configuration.WorkUnitState;
+import org.apache.gobblin.metrics.MetricContext;
+import org.apache.gobblin.metrics.event.EventSubmitter;
+
+
+/**
+ * A class that tracks KafkaExtractor statistics such as record decode time, 
#processed records, #undecodeable records etc.
+ *
+ */
+@Slf4j
+public class KafkaExtractorStatsTracker {
+  // Constants for event submission
+  public static final String TOPIC = "topic";
+  public static final String PARTITION = "partition";
+
+  private static final String GOBBLIN_KAFKA_NAMESPACE = "gobblin.kafka";
+  private static final String KAFKA_EXTRACTOR_TOPIC_METADATA_EVENT_NAME = 
"KafkaExtractorTopicMetadata";
+  private static final String LOW_WATERMARK = "lowWatermark";
+  private static final String ACTUAL_HIGH_WATERMARK = "actualHighWatermark";
+  private static final String EXPECTED_HIGH_WATERMARK = 
"expectedHighWatermark";
+  private static final String ELAPSED_TIME = "elapsedTime";
+  private static final String PROCESSED_RECORD_COUNT = "processedRecordCount";
+  private static final String UNDECODABLE_MESSAGE_COUNT = 
"undecodableMessageCount";
+  private static final String PARTITION_TOTAL_SIZE = "partitionTotalSize";
+  private static final String AVG_RECORD_PULL_TIME = "avgRecordPullTime";
+  private static final String AVG_RECORD_SIZE = "avgRecordSize";
+  private static final String READ_RECORD_TIME = "readRecordTime";
+  private static final String DECODE_RECORD_TIME = "decodeRecordTime";
+  private static final String FETCH_MESSAGE_BUFFER_TIME = 
"fetchMessageBufferTime";
+  private static final String LAST_RECORD_HEADER_TIMESTAMP = 
"lastRecordHeaderTimestamp";
+
+  @Getter
+  private final Map<KafkaPartition, ExtractorStats> statsMap;
+  private final Set<Integer> errorPartitions;
+  private final WorkUnitState workUnitState;
+
+  //A global count of number of undecodeable messages encountered by the 
KafkaExtractor across all Kafka
+  //TopicPartitions.
+  @Getter
+  private int undecodableMessageCount = 0;
+  private List<KafkaPartition> partitions;
+
+  public KafkaExtractorStatsTracker(WorkUnitState state, List<KafkaPartition> 
partitions) {
 
 Review comment:
   A little bit nit-pick here but for ease of usage in streaming-extractor as 
well: Streaming extractor doesn't contain a list of `KafkaPartition` objects, 
what it really needs is the partition id that kafka-client can be assigned and 
consume, so does here: We just need an identifier of a kafka-partition as the 
key of `statsMap`.
   
   It would be easier if we use `List<String>` with the partitionId as the 
value here as the constructor arguments, so that you don't have to reassemble a 
`KafkaPartition` object in streaming-extractor
 
----------------------------------------------------------------
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: 338974)
    Time Spent: 1.5h  (was: 1h 20m)

> Refactor Kafka extractor statistics tracking to allow code reuse across both 
> batch and streaming execution modes
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: GOBBLIN-945
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-945
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-kafka
>    Affects Versions: 0.15.0
>            Reporter: Sudarshan Vasudevan
>            Assignee: Shirshanka Das
>            Priority: Major
>             Fix For: 0.15.0
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Current implementation of kafka extractor stats tracking is deeply integrated 
> with the batch implementation of KafkaExtractor preventing it from being used 
> in streaming Kafka extractor implementations. In addition to code reuse, the 
> refactoring allows for writing unit tests for statistics tracker. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to