You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/07/20 09:24:48 UTC

[GitHub] [hudi] zherenyu831 opened a new pull request #1851: Add user define metrics reporter

zherenyu831 opened a new pull request #1851:
URL: https://github.com/apache/hudi/pull/1851


   ## *Tips*
   - *Thank you very much for contributing to Apache Hudi.*
   - *Please review https://hudi.apache.org/contributing.html before opening a pull request.*
   
   ## What is the purpose of the pull request
   
   *(For example: This pull request adds quick-start document.)*
   
   ## Brief change log
   
   *(for example:)*
     - *Modify AnnotationLocation checkstyle rule in checkstyle.xml*
   
   ## Verify this pull request
   
   *(Please pick either of the following options)*
   
   This pull request is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This pull request is already covered by existing tests, such as *(please describe tests)*.
   
   (or)
   
   This change added tests and can be verified as follows:
   
   *(example:)*
   
     - *Added integration tests for end-to-end.*
     - *Added HoodieClientWriteTest to verify the change.*
     - *Manually verified the change by running a job locally.*
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.


----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458477384



##########
File path: hudi-client/src/main/java/org/apache/hudi/metrics/MetricsReporterFactory.java
##########
@@ -48,6 +51,10 @@ public static MetricsReporter createReporter(HoodieWriteConfig config, MetricReg
       case DATADOG:
         reporter = new DatadogMetricsReporter(config, registry);
         break;
+      case USER_DEFINED:

Review comment:
       we would remove this, please refer to https://github.com/apache/hudi/blob/master/hudi-client/src/main/java/org/apache/hudi/index/HoodieIndex.java#L56




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#issuecomment-662826386


   @leesf 
   sorry for letting you check some many times, I changed the test class name, please review it


----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#issuecomment-662300806


   @leesf 
   Fixed the code, thank you for advising, could you please check again?


----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#issuecomment-661596798


   @leesf 
   Fixed, please check


----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r459200671



##########
File path: hudi-client/src/test/java/org/apache/hudi/metrics/TestMetricsReporterFactory.java
##########
@@ -45,4 +52,53 @@ public void metricsReporterFactoryShouldReturnReporter() {
     MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry);
     assertTrue(reporter instanceof InMemoryMetricsReporter);
   }
+
+  @Test
+  public void metricsReporterFactoryShouldReturnUserDefinedReporter() {
+    when(config.getMetricReporterClassName()).thenReturn(TestMetricReporter.class.getName());
+
+    Properties props = new Properties();
+    props.setProperty("testKey", "testValue");
+
+    when(config.getProps()).thenReturn(props);
+    MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry);
+    assertTrue(reporter instanceof AbstractUserDefinedMetricsReporter);
+    assertEquals(props, ((TestMetricReporter) reporter).getProps());
+    assertEquals(registry, ((TestMetricReporter) reporter).getRegistry());
+  }
+
+  @Test
+  public void metricsReporterFactoryShouldThrowExceptionWhenMetricsReporterClassIsIllegal() {
+    when(config.getMetricReporterClassName()).thenReturn(TestIllegalMetricReporter.class.getName());
+    when(config.getProps()).thenReturn(new Properties());
+    assertThrows(HoodieException.class, () -> MetricsReporterFactory.createReporter(config, registry));
+  }
+
+  public static class TestMetricReporter extends AbstractUserDefinedMetricsReporter {
+
+    public TestMetricReporter(Properties props, MetricRegistry registry) {
+      super(props, registry);
+    }
+
+    @Override
+    public void start() {}
+
+    @Override
+    public void report() {}
+
+    @Override
+    public Closeable getReporter() {
+      return null;
+    }
+
+    @Override
+    public void stop() {}
+  }
+
+  public static class TestIllegalMetricReporter {

Review comment:
       would rename to `IllegalTestMetricsReporter`




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#issuecomment-662882896


   @leesf 
   Got it, will do thank you for merging


----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458580184



##########
File path: hudi-client/src/main/java/org/apache/hudi/config/HoodieMetricsConfig.java
##########
@@ -58,6 +59,12 @@
 
   public static final String GRAPHITE_METRIC_PREFIX = GRAPHITE_PREFIX + ".metric.prefix";
 
+  // User defined
+  public static final String USER_DEFINED_REPORTER_PREFIX = METRIC_PREFIX + ".user.defined";
+  public static final String USER_DEFINED_REPORTER_CLASS = USER_DEFINED_REPORTER_PREFIX + ".class";

Review comment:
       the key name will be like "hoodie.metrics.reporter.class" ?




----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458478400



##########
File path: hudi-client/src/main/java/org/apache/hudi/config/HoodieMetricsConfig.java
##########
@@ -58,6 +59,12 @@
 
   public static final String GRAPHITE_METRIC_PREFIX = GRAPHITE_PREFIX + ".metric.prefix";
 
+  // User defined
+  public static final String USER_DEFINED_REPORTER_PREFIX = METRIC_PREFIX + ".user.defined";
+  public static final String USER_DEFINED_REPORTER_CLASS = USER_DEFINED_REPORTER_PREFIX + ".class";
+
+  public static final String DEFAULT_USER_DEFINED_REPORTER_CLASS = DefaultUserDefinedMetricsReporter.class.getName();

Review comment:
       DEFUALT would be empty string. also please refer to https://github.com/apache/hudi/blob/5e7ab11e2ead23428ed5089421f2abd6433fe8e5/hudi-client/src/main/java/org/apache/hudi/config/HoodieIndexConfig.java#L42




----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#issuecomment-662828528


   > @leesf
   > sorry for letting you check some many times, I changed the test class name, please review it
   
   no worries..


----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458477826



##########
File path: hudi-client/src/main/java/org/apache/hudi/metrics/userdefined/DefaultUserDefinedMetricsReporter.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.hudi.metrics.userdefined;
+
+import com.codahale.metrics.MetricRegistry;
+
+import java.io.Closeable;
+import java.util.Properties;
+
+/**
+ * Used for testing.

Review comment:
       if just used for testing, we would move it into test class.




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458580586



##########
File path: hudi-client/src/main/java/org/apache/hudi/metrics/userdefined/DefaultUserDefinedMetricsReporter.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.hudi.metrics.userdefined;
+
+import com.codahale.metrics.MetricRegistry;
+
+import java.io.Closeable;
+import java.util.Properties;
+
+/**
+ * Used for testing.

Review comment:
       Moved to test classes




----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458671774



##########
File path: hudi-client/src/test/java/org/apache/hudi/metrics/TestIllegalMetricReporter.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.hudi.metrics;
+
+import com.codahale.metrics.MetricRegistry;
+
+import java.util.Properties;
+
+/**
+ * Test class for user defined metric reporter.
+ */
+public class TestIllegalMetricReporter {

Review comment:
       This class along with TestMetricReporter would both move to `TestMetricsReporterFactory.java` ?




----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#issuecomment-660974770


   @zherenyu831 Thanks for your contributing! would you please check the travis failure?


----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458478829



##########
File path: hudi-client/src/main/java/org/apache/hudi/config/HoodieMetricsConfig.java
##########
@@ -58,6 +59,12 @@
 
   public static final String GRAPHITE_METRIC_PREFIX = GRAPHITE_PREFIX + ".metric.prefix";
 
+  // User defined
+  public static final String USER_DEFINED_REPORTER_PREFIX = METRIC_PREFIX + ".user.defined";
+  public static final String USER_DEFINED_REPORTER_CLASS = USER_DEFINED_REPORTER_PREFIX + ".class";

Review comment:
       would rename to METRICS_REPORTER_CLASS = "metrics.reporter.class" ?




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458580464



##########
File path: hudi-client/src/main/java/org/apache/hudi/config/HoodieMetricsConfig.java
##########
@@ -58,6 +59,12 @@
 
   public static final String GRAPHITE_METRIC_PREFIX = GRAPHITE_PREFIX + ".metric.prefix";
 
+  // User defined
+  public static final String USER_DEFINED_REPORTER_PREFIX = METRIC_PREFIX + ".user.defined";
+  public static final String USER_DEFINED_REPORTER_CLASS = USER_DEFINED_REPORTER_PREFIX + ".class";
+
+  public static final String DEFAULT_USER_DEFINED_REPORTER_CLASS = DefaultUserDefinedMetricsReporter.class.getName();

Review comment:
       Good idea, got it




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458691695



##########
File path: hudi-client/src/test/java/org/apache/hudi/metrics/TestIllegalMetricReporter.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.hudi.metrics;
+
+import com.codahale.metrics.MetricRegistry;
+
+import java.util.Properties;
+
+/**
+ * Test class for user defined metric reporter.
+ */
+public class TestIllegalMetricReporter {

Review comment:
       Ok, let me try, actually I tried before, and static public class seem could not be about to create instance ....

##########
File path: hudi-client/src/main/java/org/apache/hudi/exception/HoodieMetricsException.java
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.hudi.exception;
+
+/**
+ * <p>
+ * Exception thrown when error happens on metrics process.
+ * </p>
+ */
+public class HoodieMetricsException extends HoodieException {

Review comment:
       OK, got it




----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r459200519



##########
File path: hudi-client/src/test/java/org/apache/hudi/metrics/TestMetricsReporterFactory.java
##########
@@ -45,4 +52,53 @@ public void metricsReporterFactoryShouldReturnReporter() {
     MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry);
     assertTrue(reporter instanceof InMemoryMetricsReporter);
   }
+
+  @Test
+  public void metricsReporterFactoryShouldReturnUserDefinedReporter() {
+    when(config.getMetricReporterClassName()).thenReturn(TestMetricReporter.class.getName());
+
+    Properties props = new Properties();
+    props.setProperty("testKey", "testValue");
+
+    when(config.getProps()).thenReturn(props);
+    MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry);
+    assertTrue(reporter instanceof AbstractUserDefinedMetricsReporter);
+    assertEquals(props, ((TestMetricReporter) reporter).getProps());
+    assertEquals(registry, ((TestMetricReporter) reporter).getRegistry());
+  }
+
+  @Test
+  public void metricsReporterFactoryShouldThrowExceptionWhenMetricsReporterClassIsIllegal() {
+    when(config.getMetricReporterClassName()).thenReturn(TestIllegalMetricReporter.class.getName());
+    when(config.getProps()).thenReturn(new Properties());
+    assertThrows(HoodieException.class, () -> MetricsReporterFactory.createReporter(config, registry));
+  }
+
+  public static class TestMetricReporter extends AbstractUserDefinedMetricsReporter {

Review comment:
       would rename to `DummyMetricsReporter`




----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458477465



##########
File path: hudi-client/src/main/java/org/apache/hudi/metrics/MetricsReporterType.java
##########
@@ -22,5 +22,5 @@
  * Types of the reporter. Right now we only support Graphite. We can include JMX and CSV in the future.
  */
 public enum MetricsReporterType {
-  GRAPHITE, INMEMORY, JMX, DATADOG
+  GRAPHITE, INMEMORY, JMX, DATADOG, USER_DEFINED

Review comment:
       would remove USER_DEFINED.




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458580838



##########
File path: hudi-client/src/main/java/org/apache/hudi/metrics/MetricsReporterType.java
##########
@@ -22,5 +22,5 @@
  * Types of the reporter. Right now we only support Graphite. We can include JMX and CSV in the future.
  */
 public enum MetricsReporterType {
-  GRAPHITE, INMEMORY, JMX, DATADOG
+  GRAPHITE, INMEMORY, JMX, DATADOG, USER_DEFINED

Review comment:
       Yes, no need any more

##########
File path: hudi-client/src/main/java/org/apache/hudi/metrics/MetricsReporterFactory.java
##########
@@ -48,6 +51,10 @@ public static MetricsReporter createReporter(HoodieWriteConfig config, MetricReg
       case DATADOG:
         reporter = new DatadogMetricsReporter(config, registry);
         break;
+      case USER_DEFINED:

Review comment:
       Ok, look good




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 closed pull request #1851: Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 closed pull request #1851:
URL: https://github.com/apache/hudi/pull/1851


   


----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#issuecomment-662440954


   @leesf
   I migrated test class into TestMetricsReporterFactory, and also used HoodieException instead, please check


----------------------------------------------------------------
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



[GitHub] [hudi] leesf commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458672524



##########
File path: hudi-client/src/main/java/org/apache/hudi/exception/HoodieMetricsException.java
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.hudi.exception;
+
+/**
+ * <p>
+ * Exception thrown when error happens on metrics process.
+ * </p>
+ */
+public class HoodieMetricsException extends HoodieException {

Review comment:
       Let's use HoodieException instead of creating a new Exception class?




----------------------------------------------------------------
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



[GitHub] [hudi] leesf merged pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
leesf merged pull request #1851:
URL: https://github.com/apache/hudi/pull/1851


   


----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r459214674



##########
File path: hudi-client/src/test/java/org/apache/hudi/metrics/TestMetricsReporterFactory.java
##########
@@ -45,4 +52,53 @@ public void metricsReporterFactoryShouldReturnReporter() {
     MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry);
     assertTrue(reporter instanceof InMemoryMetricsReporter);
   }
+
+  @Test
+  public void metricsReporterFactoryShouldReturnUserDefinedReporter() {
+    when(config.getMetricReporterClassName()).thenReturn(TestMetricReporter.class.getName());
+
+    Properties props = new Properties();
+    props.setProperty("testKey", "testValue");
+
+    when(config.getProps()).thenReturn(props);
+    MetricsReporter reporter = MetricsReporterFactory.createReporter(config, registry);
+    assertTrue(reporter instanceof AbstractUserDefinedMetricsReporter);
+    assertEquals(props, ((TestMetricReporter) reporter).getProps());
+    assertEquals(registry, ((TestMetricReporter) reporter).getRegistry());
+  }
+
+  @Test
+  public void metricsReporterFactoryShouldThrowExceptionWhenMetricsReporterClassIsIllegal() {
+    when(config.getMetricReporterClassName()).thenReturn(TestIllegalMetricReporter.class.getName());
+    when(config.getProps()).thenReturn(new Properties());
+    assertThrows(HoodieException.class, () -> MetricsReporterFactory.createReporter(config, registry));
+  }
+
+  public static class TestMetricReporter extends AbstractUserDefinedMetricsReporter {

Review comment:
       That's easy




----------------------------------------------------------------
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



[GitHub] [hudi] zherenyu831 commented on a change in pull request #1851: [HUDI-1113] Add user define metrics reporter

Posted by GitBox <gi...@apache.org>.
zherenyu831 commented on a change in pull request #1851:
URL: https://github.com/apache/hudi/pull/1851#discussion_r458580184



##########
File path: hudi-client/src/main/java/org/apache/hudi/config/HoodieMetricsConfig.java
##########
@@ -58,6 +59,12 @@
 
   public static final String GRAPHITE_METRIC_PREFIX = GRAPHITE_PREFIX + ".metric.prefix";
 
+  // User defined
+  public static final String USER_DEFINED_REPORTER_PREFIX = METRIC_PREFIX + ".user.defined";
+  public static final String USER_DEFINED_REPORTER_CLASS = USER_DEFINED_REPORTER_PREFIX + ".class";

Review comment:
       the full key name will be like "hoodie.metrics.reporter.class" ?




----------------------------------------------------------------
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