This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 5a17ca2a29 [type:fix]fix logging plugin sample bug (#5429)
5a17ca2a29 is described below
commit 5a17ca2a2985eb69e12827e0702774e1d17e07fd
Author: NanMu <[email protected]>
AuthorDate: Fri Feb 2 22:46:16 2024 +0800
[type:fix]fix logging plugin sample bug (#5429)
* fix bug
* fix
* update
---------
Co-authored-by: ‘xcsnx’ <‘[email protected]’>
---
.../src/main/java/org/apache/shenyu/e2e/model/Plugin.java | 4 +++-
.../shenyu/plugin/logging/common/utils/LogCollectConfigUtils.java | 8 ++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git
a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java
b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java
index 1e5dd6b77c..991748bd4f 100644
---
a/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java
+++
b/shenyu-e2e/shenyu-e2e-common/src/main/java/org/apache/shenyu/e2e/model/Plugin.java
@@ -71,7 +71,9 @@ public enum Plugin {
LOGGING_TENCENT_CLS("loggingTencentCls", 36),
LOGGING_PULSAR("loggingPulsar", 35),
LOGGING_CLICK_HOUSE("loggingClickHouse", 38),
- BRPC("brpc", 41);
+ BRPC("brpc", 41),
+ LOGGINGHUAWEILTS("loggingHuaweiLts", 43),
+ LOGGINGRABBITMQ("loggingRabbitMQ", 45),;
private static final Logger log = LoggerFactory.getLogger(Plugin.class);
private final String id;
diff --git
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/utils/LogCollectConfigUtils.java
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/utils/LogCollectConfigUtils.java
index 1ae8bdeda5..43c4fd20e1 100644
---
a/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/utils/LogCollectConfigUtils.java
+++
b/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/utils/LogCollectConfigUtils.java
@@ -19,6 +19,7 @@ package org.apache.shenyu.plugin.logging.common.utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.plugin.logging.common.config.GenericApiConfig;
import org.apache.shenyu.plugin.logging.common.config.GenericGlobalConfig;
import
org.apache.shenyu.plugin.logging.common.handler.AbstractLogPluginDataHandler;
import org.apache.shenyu.plugin.logging.common.sampler.CountSampler;
@@ -104,8 +105,11 @@ public final class LogCollectConfigUtils {
*/
public static boolean isSampled(final ServerWebExchange exchange, final
SelectorData selectorData) {
return
Optional.ofNullable(AbstractLogPluginDataHandler.getSelectApiConfigMap().get(selectorData.getId()))
- .map(config -> config.getSampler().isSampled(exchange,
selectorData))
+ .map(GenericApiConfig::getSampler)
+ .map(sampler -> sampler.isSampled(exchange, selectorData))
.orElseGet(() ->
Optional.ofNullable(AbstractLogPluginDataHandler.getPluginGlobalConfigMap().get(selectorData.getPluginId()))
- .map(config -> config.getSampler().isSampled(exchange,
selectorData)).orElse(true));
+ .map(GenericGlobalConfig::getSampler)
+ .map(sampler -> sampler.isSampled(exchange,
selectorData))
+ .orElse(true));
}
}