✨ 打印参数
This commit is contained in:
parent
fc8834c4c5
commit
c0928a26be
|
@ -1,6 +1,7 @@
|
|||
package cn.com.xuxiaowei.boot.sentinel;
|
||||
|
||||
import cn.com.xuxiaowei.boot.sentinel.interceptor.ExecutionTimeInterceptor;
|
||||
import cn.com.xuxiaowei.boot.sentinel.utils.StringUtils;
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||
import net.bytebuddy.implementation.MethodDelegation;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
@ -22,6 +23,11 @@ public class BootSentinelAgent {
|
|||
public static void premain(String agentArgs, Instrumentation inst) {
|
||||
logger.info("BootSentinelAgent 已启动");
|
||||
|
||||
String bootSentinelPrintlnArgs = System.getenv("BOOT_SENTINEL_PRINTLN_ARGS");
|
||||
if (Boolean.TRUE.toString().equalsIgnoreCase(bootSentinelPrintlnArgs)) {
|
||||
logger.info("BootSentinelAgent 参数:{}", StringUtils.stringToMap(agentArgs));
|
||||
}
|
||||
|
||||
AgentBuilder.Transformer transformer = (builder, typeDescription, classLoader, javaModule,
|
||||
protectionDomain) -> builder.method(ElementMatchers.any())
|
||||
.intercept(MethodDelegation.to(ExecutionTimeInterceptor.class));
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package cn.com.xuxiaowei.boot.sentinel.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 探针监控项目
|
||||
*
|
||||
* @author xuxiaowei
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
/**
|
||||
* Spring 转 Map
|
||||
* @param input Spring 字符串
|
||||
* @return Map
|
||||
*/
|
||||
public static Map<String, String> stringToMap(String input) {
|
||||
return Arrays.stream(input.split(","))
|
||||
.map(pair -> pair.split("="))
|
||||
.filter(keyValue -> keyValue.length == 2)
|
||||
.collect(Collectors.toMap(keyValue -> keyValue[0], keyValue -> keyValue[1]));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue