You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/12/09 12:25:37 UTC

[GitHub] [rocketmq-spring] heihaozi opened a new pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

heihaozi opened a new pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324


   ## What is the purpose of the change
   
   Support the expansion of metrics data statistics in RocketMQ-Spring. This feature can enable:
   
    * Provide standard and diverse metrics representation(e.g. percentile, gauge, histogram).
    * Standardization of monitoring API and transport server API, and adapt to open-source monitoring components (e.g. Prometheus).
    * Integration with open-source visualization solution(e.g. Grafana).
   
   
   ## Brief changelog
   
   Created an interface called MetricExtension to record the number of messages produced or consumed. By obtaining the implementation of this interface through SPI, developers can easily write their own metrics data statistics method.
   
   ## Verifying this change
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. 
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


----------------------------------------------------------------
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] [rocketmq-spring] vongosling commented on pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
vongosling commented on pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#issuecomment-743128906


   Do we consider the possibility of using aop to finish this feature? @RongtongJin Would you like to help to design here?


----------------------------------------------------------------
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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540087344



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/EConsumerMode.java
##########
@@ -0,0 +1,29 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+public enum EConsumerMode {

Review comment:
       This is a good idea.




----------------------------------------------------------------
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] [rocketmq-spring] vongosling commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
vongosling commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r539793179



##########
File path: pom.xml
##########
@@ -176,9 +176,10 @@
                         <exclude>.github/**</exclude>
                         <exclude>src/test/resources/certs/*</exclude>
                         <exclude>src/test/**/*.log</exclude>
-                        <exclude>src/test/resources/META-INF/service/*</exclude>
+                        <exclude>**/src/main/resources/META-INF/services/*</exclude>

Review comment:
       why did you add prefix placeholder before the root directory /src?

##########
File path: rocketmq-spring-boot-samples/rocketmq-consume-demo/src/main/java/org/apache/rocketmq/samples/springboot/AtomicLongMetricExtension.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.rocketmq.samples.springboot;
+
+import org.apache.rocketmq.spring.metric.EConsumerMode;
+import org.apache.rocketmq.spring.metric.MetricExtension;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class AtomicLongMetricExtension implements MetricExtension {
+
+    private final Map<String, AtomicLong> producerMessageCountMap = new ConcurrentHashMap<>();
+    private final Map<String, AtomicLong> consumerMessageCountMap = new ConcurrentHashMap<>();
+
+    @Override
+    public void addProducerMessageCount(String topic, int count) {
+        AtomicLong atomicLong = producerMessageCountMap.computeIfAbsent(topic, t -> new AtomicLong());
+        System.out.printf("The count of producer messages for %s is %d.%n", topic, atomicLong.addAndGet(count));

Review comment:
       It's not best practice to print info in the console. you could make a switch and log it. And do not make too many copies of this class in the different submodule.

##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/EConsumerMode.java
##########
@@ -0,0 +1,29 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+public enum EConsumerMode {

Review comment:
       Please do not make an enum here. you could use the existing class.

##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/MetricExtension.java
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+public interface MetricExtension {
+
+    /**
+     * Add current count of message from the producer.
+     *
+     * @param topic topic name
+     * @param count count of message
+     */
+    void addProducerMessageCount(String topic, int count);

Review comment:
       int or long should be consistent.

##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/DefaultLitePullConsumerWithTopic.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.rocketmq.spring.core;
+
+import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
+import org.apache.rocketmq.remoting.RPCHook;
+
+public class DefaultLitePullConsumerWithTopic extends DefaultLitePullConsumer {

Review comment:
       DefaultLitePullConsumerWithTopic is not a rational name here.

##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/RocketMQTemplate.java
##########
@@ -236,6 +238,7 @@ public void setAsyncSenderExecutor(ExecutorService asyncSenderExecutor) {
             if (delayLevel > 0) {
                 rocketMsg.setDelayTimeLevel(delayLevel);
             }
+            MetricExtensionProvider.addProducerMessageCount(rocketMsg.getTopic(), 1);

Review comment:
       I suggest you use an atomic data structure instead of plus 1 here:-)

##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/MetricExtensionProvider.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+public class MetricExtensionProvider {

Review comment:
       Do not make class by yourself. I strongly recommend you use a similar service loader mode in RocketMQ. It has many backoff strategies and verified in the production environment.

##########
File path: rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/metric/MetricExtensionTest.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class MetricExtensionTest implements MetricExtension {
+
+    private static String TOPIC;
+    private static int COUNT;
+    private static EConsumerMode CONSUMER_MODE;
+
+    @Override
+    public void addProducerMessageCount(String topic, int count) {
+        TOPIC = topic;
+        COUNT = count;
+    }
+
+    @Override
+    public void addConsumerMessageCount(String topic, int count, EConsumerMode consumerMode) {
+        TOPIC = topic;
+        COUNT = count;
+        CONSUMER_MODE = consumerMode;
+    }
+
+    @Test
+    public void testAddProducerMessageCount() {
+        MetricExtensionProvider.addProducerMessageCount("topic1", 111);

Review comment:
       It could be helpful for your code convincible if you could make more corner cases, such as have you simulated the count of failures? 




----------------------------------------------------------------
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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r539993356



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/DefaultLitePullConsumerWithTopic.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.rocketmq.spring.core;
+
+import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
+import org.apache.rocketmq.remoting.RPCHook;
+
+public class DefaultLitePullConsumerWithTopic extends DefaultLitePullConsumer {

Review comment:
       Compared with DefaultLitePullConsumer, this class just has one more Topic attribute. So, I named this class DefaultLitePullConsumerWithTopic. Do you have any better suggestions for the naming of this 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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540083432



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/DefaultLitePullConsumerWithTopic.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.rocketmq.spring.core;
+
+import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
+import org.apache.rocketmq.remoting.RPCHook;
+
+public class DefaultLitePullConsumerWithTopic extends DefaultLitePullConsumer {

Review comment:
       Where can this new class be maked? What's your suggestion?




----------------------------------------------------------------
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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r539997862



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/EConsumerMode.java
##########
@@ -0,0 +1,29 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+public enum EConsumerMode {

Review comment:
       I did not find an existing enum. Do you have better suggestions?




----------------------------------------------------------------
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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540005165



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/MetricExtensionProvider.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+public class MetricExtensionProvider {

Review comment:
       The ServiceProvider is in the broker module, RocketMQ-Spring has no dependency on the broker module, so it cannot be used directly.




----------------------------------------------------------------
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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540079133



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/MetricExtensionProvider.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+public class MetricExtensionProvider {

Review comment:
       ServiceLoader is a simple Service Provder Framework provided since JDK 1.6. I think the reference description is this:  [https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html)




----------------------------------------------------------------
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] [rocketmq-spring] vongosling commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
vongosling commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r539799564



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/MetricExtensionProvider.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+public class MetricExtensionProvider {

Review comment:
       Do not make class by yourself. I strongly recommend you use a similar service loader mode in RocketMQ[1]. It has many backoff strategies and verified in the production environment.
   
   [1] https://github.com/apache/rocketmq/blob/master/broker/src/main/java/org/apache/rocketmq/broker/util/ServiceProvider.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] [rocketmq-spring] vongosling commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
vongosling commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540053683



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/core/DefaultLitePullConsumerWithTopic.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.rocketmq.spring.core;
+
+import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
+import org.apache.rocketmq.remoting.RPCHook;
+
+public class DefaultLitePullConsumerWithTopic extends DefaultLitePullConsumer {

Review comment:
       Do not make a new class here.

##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/EConsumerMode.java
##########
@@ -0,0 +1,29 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+public enum EConsumerMode {

Review comment:
       I could not find any use for this enum, if exist, please encapsulate it to the inner 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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540061198



##########
File path: pom.xml
##########
@@ -176,9 +176,10 @@
                         <exclude>.github/**</exclude>
                         <exclude>src/test/resources/certs/*</exclude>
                         <exclude>src/test/**/*.log</exclude>
-                        <exclude>src/test/resources/META-INF/service/*</exclude>
+                        <exclude>**/src/main/resources/META-INF/services/*</exclude>

Review comment:
       I tried it. When running `mvn -B clean apache-rat:check` and building RocketMQ Spring Boot, the rocketmq-spring-boot-samples project will also be checked. If I do not add the prefix placeholder, an unapproved license error will be reported. Like this: [https://travis-ci.org/github/apache/rocketmq-spring/builds/748732956](https://travis-ci.org/github/apache/rocketmq-spring/builds/748732956)




----------------------------------------------------------------
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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540000079



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/MetricExtension.java
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+public interface MetricExtension {
+
+    /**
+     * Add current count of message from the producer.
+     *
+     * @param topic topic name
+     * @param count count of message
+     */
+    void addProducerMessageCount(String topic, int count);

Review comment:
       The parameter type is always int, and long is not used.




----------------------------------------------------------------
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] [rocketmq-spring] vongosling commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
vongosling commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540051799



##########
File path: rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/metric/MetricExtensionProvider.java
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+public class MetricExtensionProvider {

Review comment:
       You could copy and make some improvements. Pls make a reference description when you do 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] [rocketmq-spring] heihaozi commented on a change in pull request #324: [ISSUE #323] Support the expansion of metrics data statistics in RocketMQ-Spring.

Posted by GitBox <gi...@apache.org>.
heihaozi commented on a change in pull request #324:
URL: https://github.com/apache/rocketmq-spring/pull/324#discussion_r540026014



##########
File path: rocketmq-spring-boot/src/test/java/org/apache/rocketmq/spring/metric/MetricExtensionTest.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.rocketmq.spring.metric;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class MetricExtensionTest implements MetricExtension {
+
+    private static String TOPIC;
+    private static int COUNT;
+    private static EConsumerMode CONSUMER_MODE;
+
+    @Override
+    public void addProducerMessageCount(String topic, int count) {
+        TOPIC = topic;
+        COUNT = count;
+    }
+
+    @Override
+    public void addConsumerMessageCount(String topic, int count, EConsumerMode consumerMode) {
+        TOPIC = topic;
+        COUNT = count;
+        CONSUMER_MODE = consumerMode;
+    }
+
+    @Test
+    public void testAddProducerMessageCount() {
+        MetricExtensionProvider.addProducerMessageCount("topic1", 111);

Review comment:
       This unit test is mainly used to test whether the SPI of MetricExtensionProvider is running normally.The scenario where the counting fails you mentioned was considered by the developer when implementing the MetricExtension interface.




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