You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/16 10:27:07 UTC

[GitHub] [dubbo] kylixs commented on a change in pull request #8785: [3.0] Refactor MetricsConfig and add empty Prometheus implementation.

kylixs commented on a change in pull request #8785:
URL: https://github.com/apache/dubbo/pull/8785#discussion_r709981120



##########
File path: dubbo-config/dubbo-config-spring/src/test/resources/org/apache/dubbo/config/spring/metrics-prometheus.xml
##########
@@ -0,0 +1,34 @@
+<!--
+  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.
+  -->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+       xmlns="http://www.springframework.org/schema/beans"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+    http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd
+    ">
+
+    <!-- current application configuration -->
+    <dubbo:application name="demo-consumer" />
+
+    <dubbo:metrics protocol="prometheus">

Review comment:
       Should we remove the `<dubbo:prometheus> ... <dubbo:prometheus/>` ?
   ```xml
   <dubbo:metrics protocol="prometheus">
       <dubbo:prometheus-exporter enabled="true" enable-http-service-discovery="true" http-service-discovery-url="localhost:8080" metrics-port="20888" metrics-path="/metrics" />
       <dubbo:prometheus-pushgateway enabled="true" base-url="localhost:9091" push-interval="30" username="username" password="password" job="job" />
   </dubbo:metrics>
   ```

##########
File path: dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/MetricsFactory.java
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.dubbo.metrics;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.extension.Adaptive;
+import org.apache.dubbo.common.extension.ExtensionScope;
+import org.apache.dubbo.common.extension.SPI;
+
+/**
+ * MetricsFactory. (SPI, Singleton, ThreadSafe)
+ */
+@SPI(value = "prometheus", scope = ExtensionScope.APPLICATION)
+public interface MetricsFactory {
+
+    /**
+     * Create metrics.
+     *
+     * @param url
+     * @return metrics
+     */
+    @Adaptive("protocol")
+    Metrics getMetrics(URL url);

Review comment:
       The name of `Metrics` / `MetricsFactory` is not very appropriate, here is a suggestion: `MetricsProvider` / `MetricsProviderFactory`

##########
File path: dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/Metrics.java
##########
@@ -14,16 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.dubbo.monitor.support;
+package org.apache.dubbo.metrics;
 
-import org.apache.dubbo.monitor.MetricsService;
-import org.apache.dubbo.rpc.model.BuiltinServiceDetector;
+import org.apache.dubbo.common.Node;
 
-public class MetricsServiceDetector implements BuiltinServiceDetector {
-
-    @Override
-    public Class<?> getService() {
-        return MetricsService.class;
-    }
+/**
+ * Monitor. (SPI, Prototype, ThreadSafe)
+ *
+ * @see org.apache.dubbo.metrics.MetricsFactory#getMetrics(org.apache.dubbo.common.URL)
+ */
+public interface Metrics extends Node, MetricsService {

Review comment:
       `MetricsProvider` should not implement `MetricsService`. I think `MetricsService` is a service that provides metrics query, not implemented by metrics provider.




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

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org