Bugfix/lettucev5 plugin (#6453)
This commit is contained in:
parent
92a0b893b5
commit
3a6c39c684
|
|
@ -15,6 +15,7 @@ Release Notes.
|
|||
* Fix NPE when Kafka reporter activated.
|
||||
* Enhance gRPC log appender to allow layout pattern.
|
||||
* Fix apm-dubbo-2.7.x-plugin memory leak due to some Dubbo RpcExceptions.
|
||||
* Fix lettuce-5.x-plugin get null host in redis sentinel mode.
|
||||
|
||||
#### OAP-Backend
|
||||
* Allow user-defined `JAVA_OPTS` in the startup script.
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ import io.lettuce.core.RedisClient;
|
|||
import io.lettuce.core.RedisURI;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RedisClientConstructorInterceptor implements InstanceConstructorInterceptor {
|
||||
|
||||
|
|
@ -30,6 +33,14 @@ public class RedisClientConstructorInterceptor implements InstanceConstructorInt
|
|||
RedisURI redisURI = (RedisURI) allArguments[1];
|
||||
RedisClient redisClient = (RedisClient) objInst;
|
||||
EnhancedInstance optionsInst = (EnhancedInstance) redisClient.getOptions();
|
||||
optionsInst.setSkyWalkingDynamicField(redisURI.getHost() + ":" + redisURI.getPort());
|
||||
StringBuilder redisPeer = new StringBuilder();
|
||||
if (StringUtil.isNotBlank(redisURI.getSentinelMasterId())) {
|
||||
redisPeer.append(redisURI.getSentinelMasterId()).append("[").append(
|
||||
redisURI.getSentinels().stream().map(r -> r.getHost() + ":" + r.getPort())
|
||||
.collect(Collectors.joining(","))).append("]");
|
||||
} else {
|
||||
redisPeer.append(redisURI.getHost()).append(":").append(redisURI.getPort());
|
||||
}
|
||||
optionsInst.setSkyWalkingDynamicField(redisPeer.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue