use of com.navercorp.pinpoint.plugin.redis.EndPointAccessor in project pinpoint by naver.
the class JedisPipelineMethodInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
String endPoint = null;
if (target instanceof EndPointAccessor) {
endPoint = ((EndPointAccessor) target)._$PINPOINT$_getEndPoint();
}
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null && invocation.getAttachment() != null && invocation.getAttachment() instanceof CommandContext) {
final CommandContext commandContext = (CommandContext) invocation.getAttachment();
logger.debug("Check command context {}", commandContext);
if (io) {
final StringBuilder sb = new StringBuilder();
sb.append("write=").append(commandContext.getWriteElapsedTime());
if (commandContext.isWriteFail()) {
sb.append("(fail)");
}
sb.append(", read=").append(commandContext.getReadElapsedTime());
if (commandContext.isReadFail()) {
sb.append("(fail)");
}
recorder.recordAttribute(AnnotationKey.ARGS0, sb.toString());
}
// clear
invocation.removeAttachment();
}
recorder.recordApi(getMethodDescriptor());
recorder.recordEndPoint(endPoint != null ? endPoint : "Unknown");
recorder.recordDestinationId(RedisConstants.REDIS.getName());
recorder.recordServiceType(RedisConstants.REDIS);
recorder.recordException(throwable);
}
use of com.navercorp.pinpoint.plugin.redis.EndPointAccessor in project pinpoint by naver.
the class JedisConstructorInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
if (!validate(target, args)) {
return;
}
final StringBuilder endPoint = new StringBuilder();
// first arg is host
if (args[0] instanceof String) {
endPoint.append(args[0]);
// second arg is port
if (args.length >= 2 && args[1] instanceof Integer) {
endPoint.append(":").append(args[1]);
} else {
// set default port
endPoint.append(":").append(6379);
}
} else if (args[0] instanceof URI) {
final URI uri = (URI) args[0];
endPoint.append(uri.getHost());
endPoint.append(":");
endPoint.append(uri.getPort());
} else if (args[0] instanceof JedisShardInfo) {
final JedisShardInfo info = (JedisShardInfo) args[0];
endPoint.append(info.getHost());
endPoint.append(":");
endPoint.append(info.getPort());
}
((EndPointAccessor) target)._$PINPOINT$_setEndPoint(endPoint.toString());
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
}
use of com.navercorp.pinpoint.plugin.redis.EndPointAccessor in project pinpoint by naver.
the class JedisMethodInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
String endPoint = null;
if (target instanceof EndPointAccessor) {
endPoint = ((EndPointAccessor) target)._$PINPOINT$_getEndPoint();
}
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null && invocation.getAttachment() != null && invocation.getAttachment() instanceof CommandContext) {
final CommandContext commandContext = (CommandContext) invocation.getAttachment();
logger.debug("Check command context {}", commandContext);
if (io) {
final StringBuilder sb = new StringBuilder();
sb.append("write=").append(commandContext.getWriteElapsedTime());
if (commandContext.isWriteFail()) {
sb.append("(fail)");
}
sb.append(", read=").append(commandContext.getReadElapsedTime());
if (commandContext.isReadFail()) {
sb.append("(fail)");
}
recorder.recordAttribute(AnnotationKey.ARGS0, sb.toString());
}
// clear
invocation.removeAttachment();
}
recorder.recordApi(getMethodDescriptor());
recorder.recordEndPoint(endPoint != null ? endPoint : "Unknown");
recorder.recordDestinationId(RedisConstants.REDIS.getName());
recorder.recordServiceType(RedisConstants.REDIS);
recorder.recordException(throwable);
}
Aggregations