You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/06/16 11:07:44 UTC

[shardingsphere] branch master updated: Add logger filter to reduce scaling IT useless logs (#18395)

This is an automated email from the ASF dual-hosted git repository.

zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 010edeea525 Add logger filter to reduce scaling IT useless logs (#18395)
010edeea525 is described below

commit 010edeea525a695a2c112bd5843c76a7134ad295
Author: azexcy <10...@users.noreply.github.com>
AuthorDate: Thu Jun 16 19:07:33 2022 +0800

    Add logger filter to reduce scaling IT useless logs (#18395)
---
 .../framework/helper/ScalingCaseHelper.java        |  3 +-
 .../data/pipeline/logger/ScalingLoggerFilter.java  | 53 ++++++++++++++++++++++
 .../resources/env/scenario/general/postgresql.xml  |  4 +-
 .../src/test/resources/logback-test.xml            |  3 ++
 4 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
index 34d371f166d..6675d33bf87 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/framework/helper/ScalingCaseHelper.java
@@ -27,6 +27,7 @@ import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
 
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
@@ -87,7 +88,7 @@ public final class ScalingCaseHelper {
             } else {
                 orderData.add(new Object[]{keyGenerateAlgorithm.generateKey(), orderId, userId, generateString(6), randomInt,
                         BigDecimal.valueOf(generateDouble(1, 100)), true, generateString(2), generateString(2), generateFloat(),
-                        generateDouble(0, 1000)});
+                        generateDouble(0, 1000), LocalDateTime.now(), OffsetDateTime.now()});
             }
             orderItemData.add(new Object[]{keyGenerateAlgorithm.generateKey(), orderId, userId, "SUCCESS"});
         }
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/logger/ScalingLoggerFilter.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/logger/ScalingLoggerFilter.java
new file mode 100644
index 00000000000..8bb072ab546
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/java/org/apache/shardingsphere/integration/data/pipeline/logger/ScalingLoggerFilter.java
@@ -0,0 +1,53 @@
+/*
+ * 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.shardingsphere.integration.data.pipeline.logger;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.filter.Filter;
+import ch.qos.logback.core.spi.FilterReply;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ScalingLoggerFilter extends Filter<ILoggingEvent> {
+    
+    private static final List<String> IGNORE_LOGGER_NAMES = Arrays.asList(":mysql", ":zookeeper", ":postgresql");
+    
+    private static final String[] IGNORE_ATOMIKOS_ARGS = new String[]{"- tips & advice", "- working demos", "- access to the full documentation",
+            "- special exclusive bonus offers not available to others"};
+    
+    @Override
+    public FilterReply decide(final ILoggingEvent event) {
+        if (IGNORE_LOGGER_NAMES.contains(event.getLoggerName())) {
+            return FilterReply.DENY;
+        }
+        if (":Scaling-Proxy".equals(event.getLoggerName())) {
+            for (Object each : event.getArgumentArray()) {
+                String arg = each.toString();
+                if (StringUtils.isBlank(arg)) {
+                    continue;
+                }
+                if (StringUtils.containsIgnoreCase(arg, "atomikos") || StringUtils.containsAny(arg, IGNORE_ATOMIKOS_ARGS)) {
+                    return FilterReply.DENY;
+                }
+            }
+        }
+        return FilterReply.NEUTRAL;
+    }
+}
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml
index 79553212b68..494e0568672 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/env/scenario/general/postgresql.xml
@@ -60,8 +60,8 @@
     
     <full-insert-order>
         INSERT INTO
-        test.t_order(id,order_id,user_id,status,t_int2,t_numeric,t_bool, t_char,t_varchar,t_float,t_double)
-        VALUES (?,?,?,?,?,?,?,?,?,?,?)
+        test.t_order(id,order_id,user_id,status,t_int2,t_numeric,t_bool,t_char,t_varchar,t_float,t_double,t_timestmap,t_timestamptz)
+        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)
     </full-insert-order>
     
     <full-insert-order-item>
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml
index 3037e476734..e2918116526 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-scaling/src/test/resources/logback-test.xml
@@ -18,12 +18,15 @@
 
 <configuration>
     <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <filter class="org.apache.shardingsphere.integration.data.pipeline.logger.ScalingLoggerFilter" />
         <encoder>
             <pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
         </encoder>
     </appender>
     <logger name="org.apache.shardingsphere.test.integration.framework.container.atomic.DockerITContainer" level="WARN" />
     <logger name="com.zaxxer.hikari.pool.ProxyConnection" level="OFF" />
+    <logger name="com.github.dockerjava" level="WARN"/>
+    
     <root level="INFO">
         <appender-ref ref="console" />
     </root>