use of com.navercorp.pinpoint.plugin.redis.jedis.CommandContext 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();
final Object attachment = getAttachment(invocation);
if (attachment instanceof CommandContext) {
final CommandContext commandContext = (CommandContext) attachment;
if (logger.isDebugEnabled()) {
logger.debug("Check command context {}", commandContext);
}
recordIo(recorder, commandContext);
// clear
invocation.removeAttachment();
}
recorder.recordApi(getMethodDescriptor());
recorder.recordEndPoint(endPoint != null ? endPoint : "Unknown");
recorder.recordDestinationId(JedisConstants.REDIS.getName());
recorder.recordServiceType(JedisConstants.REDIS);
recorder.recordException(throwable);
}
use of com.navercorp.pinpoint.plugin.redis.jedis.CommandContext in project pinpoint by naver.
the class ProtocolSendCommandAndReadMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
final Object attachment = getAttachment(invocation);
if (attachment instanceof CommandContext) {
final CommandContext commandContext = (CommandContext) attachment;
if (methodDescriptor.getMethodName().equals("sendCommand")) {
commandContext.setWriteBeginTime(System.currentTimeMillis());
} else {
commandContext.setReadBeginTime(System.currentTimeMillis());
}
if (logger.isDebugEnabled()) {
logger.debug("Set command context {}", commandContext);
}
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.plugin.redis.jedis.CommandContext in project pinpoint by naver.
the class ProtocolSendCommandAndReadMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
final Object attachment = getAttachment(invocation);
if (attachment instanceof CommandContext) {
final CommandContext commandContext = (CommandContext) attachment;
if (methodDescriptor.getMethodName().equals("sendCommand")) {
commandContext.setWriteEndTime(System.currentTimeMillis());
commandContext.setWriteFail(throwable != null);
} else {
commandContext.setReadEndTime(System.currentTimeMillis());
commandContext.setReadFail(throwable != null);
}
if (logger.isDebugEnabled()) {
logger.debug("Set command context {}", commandContext);
}
}
} catch (Throwable t) {
logger.warn("Failed to AFTER process. {}", t.getMessage(), t);
}
}
Aggregations