You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/05/29 18:40:00 UTC

[jira] [Work logged] (GOBBLIN-1168) create InstrumentedSpecStore

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

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

                Author: ASF GitHub Bot
            Created on: 29/May/20 18:39
            Start Date: 29/May/20 18:39
    Worklog Time Spent: 10m 
      Work Description: jack-moseley commented on a change in pull request #3001:
URL: https://github.com/apache/incubator-gobblin/pull/3001#discussion_r432663005



##########
File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/InstrumentedSpecStore.java
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.runtime.api;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.Timer;
+import com.google.common.base.Optional;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.configuration.State;
+import org.apache.gobblin.instrumented.Instrumented;
+import org.apache.gobblin.metrics.GobblinMetrics;
+import org.apache.gobblin.metrics.MetricContext;
+import org.apache.gobblin.metrics.ServiceMetricNames;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * Instrumented version of {@link SpecStore} automatically capturing certain metrics.
+ * Subclasses should implement addSpecImpl instead of addSpec and so on.
+ */
+public abstract class InstrumentedSpecStore implements SpecStore {
+  private Optional<Timer> getTimer;
+  private Optional<Timer> existsTimer;
+  private Optional<Timer> deleteTimer;
+  private Optional<Timer> addTimer;
+  private Optional<Timer> updateTimer;
+  private Optional<Timer> getAllTimer;
+  private Optional<Timer> getURIsTimer;
+  private MetricContext metricContext;
+  private final boolean instrumentationEnabled;
+
+  public InstrumentedSpecStore(Config config, SpecSerDe specSerDe) {
+    this.instrumentationEnabled = GobblinMetrics.isEnabled(new State(ConfigUtils.configToProperties(config)));
+    this.metricContext = Instrumented.getMetricContext(new State(), getClass());
+    if (instrumentationEnabled) {
+      this.getTimer = Optional.of(this.metricContext.timer(getClass() + "-GET"));
+      this.existsTimer = Optional.of(this.metricContext.timer(
+          MetricRegistry.name(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX,getClass().getSimpleName(), "-EXISTS")));

Review comment:
       Can we separate these lines to a `createTimer(String suffix)` method to remove repeated code?

##########
File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/InstrumentedSpecStore.java
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.runtime.api;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.Timer;
+import com.google.common.base.Optional;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.configuration.State;
+import org.apache.gobblin.instrumented.Instrumented;
+import org.apache.gobblin.metrics.GobblinMetrics;
+import org.apache.gobblin.metrics.MetricContext;
+import org.apache.gobblin.metrics.ServiceMetricNames;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * Instrumented version of {@link SpecStore} automatically capturing certain metrics.
+ * Subclasses should implement addSpecImpl instead of addSpec and so on.
+ */
+public abstract class InstrumentedSpecStore implements SpecStore {
+  private Optional<Timer> getTimer;
+  private Optional<Timer> existsTimer;
+  private Optional<Timer> deleteTimer;
+  private Optional<Timer> addTimer;
+  private Optional<Timer> updateTimer;
+  private Optional<Timer> getAllTimer;
+  private Optional<Timer> getURIsTimer;
+  private MetricContext metricContext;
+  private final boolean instrumentationEnabled;
+
+  public InstrumentedSpecStore(Config config, SpecSerDe specSerDe) {
+    this.instrumentationEnabled = GobblinMetrics.isEnabled(new State(ConfigUtils.configToProperties(config)));
+    this.metricContext = Instrumented.getMetricContext(new State(), getClass());
+    if (instrumentationEnabled) {
+      this.getTimer = Optional.of(this.metricContext.timer(getClass() + "-GET"));
+      this.existsTimer = Optional.of(this.metricContext.timer(
+          MetricRegistry.name(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX,getClass().getSimpleName(), "-EXISTS")));
+      this.deleteTimer = Optional.of(this.metricContext.timer(
+          MetricRegistry.name(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX,getClass().getSimpleName(), "-DELETE")));
+      this.addTimer = Optional.of(this.metricContext.timer(
+          MetricRegistry.name(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX,getClass().getSimpleName(), "-ADD")));
+      this.updateTimer = Optional.of(this.metricContext.timer(
+          MetricRegistry.name(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX,getClass().getSimpleName(), "-UPDATE")));
+      this.getAllTimer = Optional.of(this.metricContext.timer(
+          MetricRegistry.name(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX,getClass().getSimpleName(), "-GETALL")));
+      this.getURIsTimer = Optional.of(this.metricContext.timer(
+          MetricRegistry.name(ServiceMetricNames.GOBBLIN_SERVICE_PREFIX,getClass().getSimpleName(), "-GETURIS")));
+    } else {
+      this.getTimer = Optional.absent();
+      this.existsTimer = Optional.absent();
+      this.deleteTimer = Optional.absent();
+      this.addTimer = Optional.absent();
+      this.updateTimer = Optional.absent();
+      this.getAllTimer = Optional.absent();
+      this.getURIsTimer = Optional.absent();
+    }
+  }
+
+  @Override
+  public boolean exists(URI specUri) throws IOException {
+    if (instrumentationEnabled) {

Review comment:
       Shouldn't these be `!instrumentationEnabled`?

##########
File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/spec_store/FSSpecStore.java
##########
@@ -45,6 +48,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import avro.shaded.com.google.common.collect.Iterators;

Review comment:
       Why's this import added, is this intentional?

##########
File path: gobblin-runtime/src/main/java/org/apache/gobblin/runtime/api/InstrumentedSpecStore.java
##########
@@ -0,0 +1,172 @@
+/*
+ * 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.runtime.api;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.Timer;
+import com.google.common.base.Optional;
+import com.typesafe.config.Config;
+
+import org.apache.gobblin.configuration.State;
+import org.apache.gobblin.instrumented.Instrumented;
+import org.apache.gobblin.metrics.GobblinMetrics;
+import org.apache.gobblin.metrics.MetricContext;
+import org.apache.gobblin.metrics.ServiceMetricNames;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * Instrumented version of {@link SpecStore} automatically capturing certain metrics.
+ * Subclasses should implement addSpecImpl instead of addSpec and so on.
+ */
+public abstract class InstrumentedSpecStore implements SpecStore {
+  private Optional<Timer> getTimer;
+  private Optional<Timer> existsTimer;
+  private Optional<Timer> deleteTimer;
+  private Optional<Timer> addTimer;
+  private Optional<Timer> updateTimer;
+  private Optional<Timer> getAllTimer;
+  private Optional<Timer> getURIsTimer;
+  private MetricContext metricContext;
+  private final boolean instrumentationEnabled;
+
+  public InstrumentedSpecStore(Config config, SpecSerDe specSerDe) {
+    this.instrumentationEnabled = GobblinMetrics.isEnabled(new State(ConfigUtils.configToProperties(config)));
+    this.metricContext = Instrumented.getMetricContext(new State(), getClass());
+    if (instrumentationEnabled) {
+      this.getTimer = Optional.of(this.metricContext.timer(getClass() + "-GET"));

Review comment:
       Why is this the only one without `GOBBLIN_SERVICE_PREFIX`?




----------------------------------------------------------------
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:
users@infra.apache.org


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

            Worklog Id:     (was: 438895)
    Remaining Estimate: 0h
            Time Spent: 10m

> create InstrumentedSpecStore
> ----------------------------
>
>                 Key: GOBBLIN-1168
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1168
>             Project: Apache Gobblin
>          Issue Type: Improvement
>            Reporter: Arjun Singh Bora
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> create InstrumentedSpecStore to add metrics in all SpecStore implementations



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