You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/07/13 10:45:33 UTC

[GitHub] [flink] Myasuka opened a new pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Myasuka opened a new pull request #12883:
URL: https://github.com/apache/flink/pull/12883


   ## What is the purpose of the change
   
   Ensure metric reporters could be loaded via SPI.
   
   
   ## Brief change log
   
     - Rename `META-INF.service` folder in `flink-metrics-influxdb` to `META-INF.services` to ensure influxdb metric reporter could be loaded via SPI.
     -  Added tests to ensure `flink-metrics-datadog`, `flink-metrics-graphite`, `flink-metrics-influxdb`, `flink-metrics-jmx`, `flink-metrics-prometheus`, `flink-metrics-slf4j` and `flink-metrics-statsd` could load metric reporter factory via SPI.
   
   
   ## Verifying this change
   
   This change added `*ReporterFactoryTest` tests.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): no
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
     - The serializers: no
     - The runtime per-record code paths (performance sensitive): no
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
     - The S3 file system connector: no
   
   ## Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature documented? not applicable
   


----------------------------------------------------------------
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] [flink] zentol commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r454268481



##########
File path: flink-metrics/flink-metrics-datadog/src/test/java/org/apache/flink/metrics/datadog/DatadogHttpReporterFactoryTest.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.flink.metrics.datadog;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Tests for the {@link DatadogHttpReporterFactory}.
+ */
+public class DatadogHttpReporterFactoryTest extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		Set<Class<? extends MetricReporterFactory>> loadedFactories = StreamSupport

Review comment:
       What I meant was to have this method:
   ```
   public static void testMetricReporterSetupViaSPI(Class<MetricReporterFactory> clazz) {
   	Set<Class<? extends MetricReporterFactory>> loadedFactories = StreamSupport
   		.stream(ServiceLoader.load(MetricReporterFactory.class).iterator(), false)
   		.map(MetricReporterFactory::getClass)
   		.collect(Collectors.toSet());
   	assertThat(loadedFactories , hasItems(clazz));
   }
   ```
   in flink-metrics-core, and the reporter tests just call 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] [flink] zentol commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r454222012



##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricReporterSetupTestBase.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.flink.runtime.metrics;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * The base class to verify metric reporter factory.
+ */
+public abstract class MetricReporterSetupTestBase extends TestLogger {

Review comment:
       It's fine to duplicate things. Factory support is optional after all, and having this as a simple opt-in method that external reporter implementations could use without interfering with class structures is useful.
   
   We already see the downsides of inheritance in this PR; the test method must be unnecessarily complex since it must support the Prometheus case where there are multiple reporters, with a signature that for all other reporters doesn't make sense.




----------------------------------------------------------------
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] [flink] Myasuka commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
Myasuka commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r454256668



##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricReporterSetupTestBase.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.flink.runtime.metrics;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * The base class to verify metric reporter factory.
+ */
+public abstract class MetricReporterSetupTestBase extends TestLogger {

Review comment:
       Okay, I'll update the PR with duplicate test methods to see the final effect.




----------------------------------------------------------------
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] [flink] flinkbot commented on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 38cebe617ef8ec1088744d750b6887205a5b1a6e UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot commented on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657485860


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit 38cebe617ef8ec1088744d750b6887205a5b1a6e (Mon Jul 13 10:47:52 UTC 2020)
   
   **Warnings:**
    * **6 pom.xml files were touched**: Check for build and licensing issues.
    * No documentation files were touched! Remember to keep the Flink docs up to date!
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     }, {
       "hash" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e1e8fc29efbc2d55a12e315b0005dde609ffe3cf Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462) 
   * 93616ee036d921efea80c8003e408d35339cc4ec UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     }, {
       "hash" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500",
       "triggerID" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "triggerType" : "PUSH"
     }, {
       "hash" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4504",
       "triggerID" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 25d465768bdf87bd31e0ca9b5749344c35c919d5 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4504) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     }, {
       "hash" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500",
       "triggerID" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "triggerType" : "PUSH"
     }, {
       "hash" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4504",
       "triggerID" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 93616ee036d921efea80c8003e408d35339cc4ec Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500) 
   * 25d465768bdf87bd31e0ca9b5749344c35c919d5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4504) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 38cebe617ef8ec1088744d750b6887205a5b1a6e Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] Myasuka commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
Myasuka commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r454256107



##########
File path: flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterFactoryTest.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.flink.metrics.slf4j;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.runtime.metrics.MetricReporterSetupTestBase;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests for loading the {@link Slf4jReporterFactory}.
+ */
+public class Slf4jReporterFactoryTest extends MetricReporterSetupTestBase {
+
+	@Override
+	protected List<Class<? extends MetricReporterFactory>> getMetricReporterFactoryClass() {

Review comment:
       After looking at the `PrometheusReporterEndToEndITCase`, I agree that it has already focused on this and I'll skip to cover on `slf4j` and `Prometheus` modules.




----------------------------------------------------------------
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] [flink] Myasuka commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
Myasuka commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r453804594



##########
File path: flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterFactoryTest.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.flink.metrics.slf4j;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.runtime.metrics.MetricReporterSetupTestBase;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests for loading the {@link Slf4jReporterFactory}.
+ */
+public class Slf4jReporterFactoryTest extends MetricReporterSetupTestBase {
+
+	@Override
+	protected List<Class<? extends MetricReporterFactory>> getMetricReporterFactoryClass() {

Review comment:
       I think e2e test does not focus on this feature and unit test should just focus on one thing. If we change the implementation of e2e test one day, who would guarantee the SPI work successfully?
   I still prefer to include `slf4j` and `Prometheus` in the test scopes especially we already include tests for the rest 5 reporters.




----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     }, {
       "hash" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500",
       "triggerID" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "triggerType" : "PUSH"
     }, {
       "hash" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e1e8fc29efbc2d55a12e315b0005dde609ffe3cf Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462) 
   * 93616ee036d921efea80c8003e408d35339cc4ec Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500) 
   * 25d465768bdf87bd31e0ca9b5749344c35c919d5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] zentol merged pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
zentol merged pull request #12883:
URL: https://github.com/apache/flink/pull/12883


   


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 38cebe617ef8ec1088744d750b6887205a5b1a6e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] Myasuka commented on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
Myasuka commented on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657485011


   @zentol could you please take a review?


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 38cebe617ef8ec1088744d750b6887205a5b1a6e Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438) 
   * e1e8fc29efbc2d55a12e315b0005dde609ffe3cf UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] zentol commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r454219156



##########
File path: flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterFactoryTest.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.flink.metrics.slf4j;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.runtime.metrics.MetricReporterSetupTestBase;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests for loading the {@link Slf4jReporterFactory}.
+ */
+public class Slf4jReporterFactoryTest extends MetricReporterSetupTestBase {
+
+	@Override
+	protected List<Class<? extends MetricReporterFactory>> getMetricReporterFactoryClass() {

Review comment:
       The Prometheus e2e test very much focuses on this, and tests all configurations one can think of (jar in plugins/lib, loaded via reflection/factory).
   The reason it is necessary to test as an e2e test is that this feature working in production is reliant on the packaging; if the services stuff isn't included in the jar then it just won't work, and the unit test cannot catch that.




----------------------------------------------------------------
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] [flink] Myasuka commented on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
Myasuka commented on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657527860


   @flinkbot run azure


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     }, {
       "hash" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500",
       "triggerID" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e1e8fc29efbc2d55a12e315b0005dde609ffe3cf Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462) 
   * 93616ee036d921efea80c8003e408d35339cc4ec Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 38cebe617ef8ec1088744d750b6887205a5b1a6e Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438) 
   * e1e8fc29efbc2d55a12e315b0005dde609ffe3cf Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] Myasuka commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
Myasuka commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r453777756



##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricReporterSetupTestBase.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.flink.runtime.metrics;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * The base class to verify metric reporter factory.
+ */
+public abstract class MetricReporterSetupTestBase extends TestLogger {

Review comment:
       If we do not inherit from a base class, we need to add this test method in 5 modules: `flink-metrics-datadog`, `flink-metrics-graphite`, `flink-metrics-influxdb`, `flink-metrics-jmx` and `flink-metrics-statsd` (if we give the background knowledge that Prometheus and slf4j reporter has been used in e2e tests). From my point of view, this would be too redundant. 
   I could move the base test class from `flink-runtime` to `flink-metrics-core`  module to get rid of dependency of `flink-runtime` even they're in test scope. What do you think?




----------------------------------------------------------------
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] [flink] zentol commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
zentol commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r453633452



##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricReporterSetupTestBase.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.flink.runtime.metrics;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * The base class to verify metric reporter factory.
+ */
+public abstract class MetricReporterSetupTestBase extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		Iterator<MetricReporterFactory> factoryIterator = ReporterSetup.getAllReporterFactoriesViaSPI();

Review comment:
       It would be good to get rid of the dependency to flink-runtime; this change goes contrary to our goals of separating the metric modules from flink-runtime.
   The ServiceLoader mechanism is standardized, so it's fine to just call `ServiceLoader.load(MetricReporterFactory.class).iterator()` here.

##########
File path: flink-metrics/flink-metrics-prometheus/src/test/java/org/apache/flink/metrics/prometheus/PrometheusMetricReporterFactoryTest.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.flink.metrics.prometheus;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.runtime.metrics.MetricReporterSetupTestBase;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Tests for loading the {@link PrometheusPushGatewayReporterFactory} and {@link PrometheusReporterFactory}.
+ */
+public class PrometheusMetricReporterFactoryTest extends MetricReporterSetupTestBase {

Review comment:
       redundant as we have a e2e test covering it, which is preferable. I'd only add this to reporters that are not otherwise covered as a band-aid.

##########
File path: flink-metrics/flink-metrics-slf4j/src/test/java/org/apache/flink/metrics/slf4j/Slf4jReporterFactoryTest.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.flink.metrics.slf4j;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.runtime.metrics.MetricReporterSetupTestBase;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests for loading the {@link Slf4jReporterFactory}.
+ */
+public class Slf4jReporterFactoryTest extends MetricReporterSetupTestBase {
+
+	@Override
+	protected List<Class<? extends MetricReporterFactory>> getMetricReporterFactoryClass() {

Review comment:
       redundant due to usage in e2e tests.

##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricReporterSetupTestBase.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.flink.runtime.metrics;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * The base class to verify metric reporter factory.
+ */
+public abstract class MetricReporterSetupTestBase extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		Iterator<MetricReporterFactory> factoryIterator = ReporterSetup.getAllReporterFactoriesViaSPI();
+		Set<String> metricReporterFactoryClasses = getMetricReporterFactoryClass().stream().map(Class::getCanonicalName).collect(Collectors.toSet());
+		assertFalse(metricReporterFactoryClasses.isEmpty());
+		while (factoryIterator.hasNext()) {
+			MetricReporterFactory metricReporterFactory = factoryIterator.next();

Review comment:
       ```
   public static void testMetricReporterSetupViaSPI(Class<MetricReporterFactory> clazz) {
   	Set<Class<? extends MetricReporterFactory>> loadedFactories = StreamSupport
   		.stream(ServiceLoader.load(MetricReporterFactory.class).iterator(), false)
   		.map(MetricReporterFactory::getClass)
   		.collect(Collectors.toSet());
   	assertThat(loadedFactories , hasItems(clazz));
   }
   ```

##########
File path: flink-runtime/src/test/java/org/apache/flink/runtime/metrics/MetricReporterSetupTestBase.java
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.flink.runtime.metrics;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * The base class to verify metric reporter factory.
+ */
+public abstract class MetricReporterSetupTestBase extends TestLogger {

Review comment:
       Let's not introduce inheritance for this. The test could just be a method that is being called with the factory 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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     }, {
       "hash" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500",
       "triggerID" : "93616ee036d921efea80c8003e408d35339cc4ec",
       "triggerType" : "PUSH"
     }, {
       "hash" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4504",
       "triggerID" : "25d465768bdf87bd31e0ca9b5749344c35c919d5",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e1e8fc29efbc2d55a12e315b0005dde609ffe3cf Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462) 
   * 93616ee036d921efea80c8003e408d35339cc4ec Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4500) 
   * 25d465768bdf87bd31e0ca9b5749344c35c919d5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4504) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] flinkbot edited a comment on pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12883:
URL: https://github.com/apache/flink/pull/12883#issuecomment-657495689


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4438",
       "triggerID" : "38cebe617ef8ec1088744d750b6887205a5b1a6e",
       "triggerType" : "PUSH"
     }, {
       "hash" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462",
       "triggerID" : "e1e8fc29efbc2d55a12e315b0005dde609ffe3cf",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * e1e8fc29efbc2d55a12e315b0005dde609ffe3cf Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4462) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


----------------------------------------------------------------
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] [flink] Myasuka commented on a change in pull request #12883: [FLINK-18573][metrics] Ensure metric reporters could be loaded via SPI

Posted by GitBox <gi...@apache.org>.
Myasuka commented on a change in pull request #12883:
URL: https://github.com/apache/flink/pull/12883#discussion_r454322470



##########
File path: flink-metrics/flink-metrics-datadog/src/test/java/org/apache/flink/metrics/datadog/DatadogHttpReporterFactoryTest.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.flink.metrics.datadog;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Tests for the {@link DatadogHttpReporterFactory}.
+ */
+public class DatadogHttpReporterFactoryTest extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		Set<Class<? extends MetricReporterFactory>> loadedFactories = StreamSupport

Review comment:
       Hmm, no wonder I feel confused that you did not want the inherent test classes but still feel okay for those redundant code as they are really not much if following this idea.
   
   Sorry for the misunderstanding, and already updated this PR  




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