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

[GitHub] [skywalking] codeglzhang opened a new pull request #7717: Fixed bug #7706. Make LogHandler of kafka-fetcher-plugin can recognize namespace.

codeglzhang opened a new pull request #7717:
URL: https://github.com/apache/skywalking/pull/7717


   Fixed the issue #7706. 
   
   <!--
       ⚠️ Please make sure to read this template first, pull requests that don't accord with this template
       maybe closed without notice.
       Texts surrounded by `<` and `>` are meant to be replaced by you, e.g. <framework name>, <issue number>.
       Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]`
   -->
   
   ### Fix <bug description or the bug issue number or bug issue link>
   - [x] Add a unit test to verify that the fix works.
   I add a new unit test class (org.apache.skywalking.oap.server.analyzer.agent.kafka.provider.handler.LogHandlerTest).
   - [x] Explain briefly why the bug exists and how to fix it.
   This bug has been described in the #7706 . To fix it, I made `LogHandler` extend `AbstractKafkaHandler` instead of `KafkaHandler` and removed `getTopic()` in the `LogHandler`.
   - [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #7706.
   - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/master/CHANGES.md).
   


-- 
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@skywalking.apache.org

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



[GitHub] [skywalking] codeglzhang commented on a change in pull request #7717: Fixed bug #7706. Make LogHandler of kafka-fetcher-plugin can recognize namespace.

Posted by GitBox <gi...@apache.org>.
codeglzhang commented on a change in pull request #7717:
URL: https://github.com/apache/skywalking/pull/7717#discussion_r709272622



##########
File path: oap-server/server-fetcher-plugin/kafka-fetcher-plugin/src/test/java/org/apache/skywalking/oap/server/analyzer/agent/kafka/provider/handler/LogHandlerTest.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.skywalking.oap.server.analyzer.agent.kafka.provider.handler;
+
+import org.apache.skywalking.oap.log.analyzer.module.LogAnalyzerModule;
+import org.apache.skywalking.oap.log.analyzer.provider.log.ILogAnalyzerService;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.mock.MockModuleManager;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.mock.MockModuleProvider;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.module.KafkaFetcherConfig;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.telemetry.TelemetryModule;
+import org.apache.skywalking.oap.server.telemetry.api.CounterMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.GaugeMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class LogHandlerTest {
+    private static final String TOPIC_NAME = "skywalking-logs";
+    private LogHandler handler = null;
+    private KafkaFetcherConfig config = new KafkaFetcherConfig();
+
+    private ModuleManager manager;
+
+    @Before

Review comment:
       Hi @kezhenxu94 , thanks for your comments. I agree with this suggestion. It makes the code cleaner.  I will update the code right away.

##########
File path: oap-server/server-fetcher-plugin/kafka-fetcher-plugin/src/main/java/org/apache/skywalking/oap/server/analyzer/agent/kafka/provider/handler/LogHandler.java
##########
@@ -41,25 +41,26 @@
 
     public LogHandler(final ModuleManager moduleManager,
                       final KafkaFetcherConfig config) {
+        super(moduleManager, config);
         this.config = config;
         this.logAnalyzerService = moduleManager.find(LogAnalyzerModule.NAME)
-                                               .provider()
-                                               .getService(ILogAnalyzerService.class);
+                .provider()

Review comment:
       ok, this is my negligence. I import the code style and fix it immediately




-- 
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@skywalking.apache.org

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



[GitHub] [skywalking] kezhenxu94 merged pull request #7717: Fixed bug #7706. Make LogHandler of kafka-fetcher-plugin can recognize namespace.

Posted by GitBox <gi...@apache.org>.
kezhenxu94 merged pull request #7717:
URL: https://github.com/apache/skywalking/pull/7717


   


-- 
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@skywalking.apache.org

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



[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #7717: Fixed bug #7706. Make LogHandler of kafka-fetcher-plugin can recognize namespace.

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #7717:
URL: https://github.com/apache/skywalking/pull/7717#discussion_r709192433



##########
File path: oap-server/server-fetcher-plugin/kafka-fetcher-plugin/src/test/java/org/apache/skywalking/oap/server/analyzer/agent/kafka/provider/handler/LogHandlerTest.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.skywalking.oap.server.analyzer.agent.kafka.provider.handler;
+
+import org.apache.skywalking.oap.log.analyzer.module.LogAnalyzerModule;
+import org.apache.skywalking.oap.log.analyzer.provider.log.ILogAnalyzerService;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.mock.MockModuleManager;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.mock.MockModuleProvider;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.module.KafkaFetcherConfig;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.telemetry.TelemetryModule;
+import org.apache.skywalking.oap.server.telemetry.api.CounterMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.GaugeMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class LogHandlerTest {
+    private static final String TOPIC_NAME = "skywalking-logs";
+    private LogHandler handler = null;
+    private KafkaFetcherConfig config = new KafkaFetcherConfig();
+
+    private ModuleManager manager;
+
+    @Before
+    public void setup() {
+        manager = new MockModuleManager() {
+            @Override
+            protected void init() {
+                register(LogAnalyzerModule.NAME, () -> new MockModuleProvider() {
+                    @Override
+                    protected void register() {
+                        registerServiceImplementation(ILogAnalyzerService.class, (ILogAnalyzerService) (log, extraLog) -> {
+
+                        });
+                    }
+                });
+                register(TelemetryModule.NAME, () -> new MockModuleProvider() {
+                    @Override
+                    protected void register() {
+                        registerServiceImplementation(MetricsCreator.class, new MetricsCreator() {
+                            @Override
+                            public CounterMetrics createCounter(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues) {
+                                return null;
+                            }
+
+                            @Override
+                            public GaugeMetrics createGauge(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues) {
+                                return null;
+                            }
+
+                            @Override
+                            public HistogramMetrics createHistogramMetric(String name, String tips, MetricsTag.Keys tagKeys, MetricsTag.Values tagValues, double... buckets) {
+                                return null;
+                            }
+                        });
+                    }
+                });
+            }
+        };
+        handler = new LogHandler(manager, config);
+    }
+
+    @Test
+    public void testGetTopic() {
+        Assert.assertEquals(handler.getTopic(), TOPIC_NAME);

Review comment:
       ```suggestion
           assertEquals(handler.getTopic(), TOPIC_NAME);
   ```

##########
File path: oap-server/server-fetcher-plugin/kafka-fetcher-plugin/src/test/java/org/apache/skywalking/oap/server/analyzer/agent/kafka/provider/handler/LogHandlerTest.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.skywalking.oap.server.analyzer.agent.kafka.provider.handler;
+
+import org.apache.skywalking.oap.log.analyzer.module.LogAnalyzerModule;
+import org.apache.skywalking.oap.log.analyzer.provider.log.ILogAnalyzerService;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.mock.MockModuleManager;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.mock.MockModuleProvider;
+import org.apache.skywalking.oap.server.analyzer.agent.kafka.module.KafkaFetcherConfig;
+import org.apache.skywalking.oap.server.library.module.ModuleManager;
+import org.apache.skywalking.oap.server.telemetry.TelemetryModule;
+import org.apache.skywalking.oap.server.telemetry.api.CounterMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.GaugeMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator;
+import org.apache.skywalking.oap.server.telemetry.api.MetricsTag;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class LogHandlerTest {
+    private static final String TOPIC_NAME = "skywalking-logs";
+    private LogHandler handler = null;
+    private KafkaFetcherConfig config = new KafkaFetcherConfig();
+
+    private ModuleManager manager;
+
+    @Before

Review comment:
       The `setup` method can be simplified with
   
   ```java
   
       @Before
       public void setup() {
           final ModuleManager manager = mock(ModuleManager.class, RETURNS_DEEP_STUBS);
           when(manager.find(LogAnalyzerModule.NAME).provider().getService(any()))
               .thenReturn(mock(ILogAnalyzerService.class));
           when(manager.find(TelemetryModule.NAME).provider().getService(any()))
               .thenReturn(mock(MetricsCreator.class));
           handler = new LogHandler(manager, config);
       }
   ```




-- 
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@skywalking.apache.org

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



[GitHub] [skywalking] kezhenxu94 commented on a change in pull request #7717: Fixed bug #7706. Make LogHandler of kafka-fetcher-plugin can recognize namespace.

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #7717:
URL: https://github.com/apache/skywalking/pull/7717#discussion_r709240592



##########
File path: oap-server/server-fetcher-plugin/kafka-fetcher-plugin/src/main/java/org/apache/skywalking/oap/server/analyzer/agent/kafka/provider/handler/LogHandler.java
##########
@@ -41,25 +41,26 @@
 
     public LogHandler(final ModuleManager moduleManager,
                       final KafkaFetcherConfig config) {
+        super(moduleManager, config);
         this.config = config;
         this.logAnalyzerService = moduleManager.find(LogAnalyzerModule.NAME)
-                                               .provider()
-                                               .getService(ILogAnalyzerService.class);
+                .provider()

Review comment:
       You should import our code style settings file and these changes will not be made




-- 
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@skywalking.apache.org

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