Search in sources :

Example 1 with EndPointAccessor

use of com.navercorp.pinpoint.plugin.redis.lettuce.EndPointAccessor in project pinpoint by naver.

the class AttachEndPointInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    try {
        if (!validate(target, result)) {
            return;
        }
        final String endPoint = ((EndPointAccessor) target)._$PINPOINT$_getEndPoint();
        if (result instanceof CompletableFuture) {
            StatefulRedisClusterConnectionImpl statefulRedisClusterConnection = (StatefulRedisClusterConnectionImpl) ((CompletableFuture) result).get();
            ((EndPointAccessor) statefulRedisClusterConnection)._$PINPOINT$_setEndPoint(endPoint);
            return;
        }
        ((EndPointAccessor) result)._$PINPOINT$_setEndPoint(endPoint);
    } catch (Throwable t) {
        if (logger.isWarnEnabled()) {
            logger.warn("Failed to AFTER process. {}", t.getMessage(), t);
        }
    }
}
Also used : EndPointAccessor(com.navercorp.pinpoint.plugin.redis.lettuce.EndPointAccessor) CompletableFuture(java.util.concurrent.CompletableFuture) StatefulRedisClusterConnectionImpl(io.lettuce.core.cluster.StatefulRedisClusterConnectionImpl)

Example 2 with EndPointAccessor

use of com.navercorp.pinpoint.plugin.redis.lettuce.EndPointAccessor in project pinpoint by naver.

the class RedisClientConstructorInterceptor method before.

@Override
public void before(Object target, Object[] args) {
    if (isDebug) {
        logger.beforeInterceptor(target, args);
    }
    try {
        if (!validate(target, args)) {
            return;
        }
        final RedisURI redisURI = (RedisURI) args[1];
        final String endPoint = HostAndPort.toHostAndPortString(redisURI.getHost(), redisURI.getPort());
        ((EndPointAccessor) target)._$PINPOINT$_setEndPoint(endPoint);
    } catch (Throwable t) {
        if (logger.isWarnEnabled()) {
            logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
        }
    }
}
Also used : EndPointAccessor(com.navercorp.pinpoint.plugin.redis.lettuce.EndPointAccessor) RedisURI(io.lettuce.core.RedisURI)

Aggregations

EndPointAccessor (com.navercorp.pinpoint.plugin.redis.lettuce.EndPointAccessor)2 RedisURI (io.lettuce.core.RedisURI)1 StatefulRedisClusterConnectionImpl (io.lettuce.core.cluster.StatefulRedisClusterConnectionImpl)1 CompletableFuture (java.util.concurrent.CompletableFuture)1