use of com.navercorp.pinpoint.plugin.arcus.ServiceCodeAccessor in project pinpoint by naver.
the class FutureGetInterceptor method doInAfterTrace.
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordDestinationId("MEMCACHED");
recorder.recordServiceType(ArcusConstants.MEMCACHED_FUTURE_GET);
if (!(target instanceof OperationAccessor)) {
logger.info("operation not found");
return;
}
// find the target node
final Operation op = ((OperationAccessor) target)._$PINPOINT$_getOperation();
if (op == null) {
logger.info("operation is null");
return;
}
recorder.recordException(op.getException());
final MemcachedNode handlingNode = op.getHandlingNode();
if (handlingNode != null) {
final String endPoint = getEndPoint(handlingNode);
if (endPoint != null) {
recorder.recordEndPoint(endPoint);
}
recorder.recordException(op.getException());
} else {
logger.info("no handling node");
}
if (op instanceof ServiceCodeAccessor) {
// determine the service type
String serviceCode = ((ServiceCodeAccessor) op)._$PINPOINT$_getServiceCode();
if (serviceCode != null) {
recorder.recordDestinationId(serviceCode);
recorder.recordServiceType(ArcusConstants.ARCUS_FUTURE_GET);
}
}
}
use of com.navercorp.pinpoint.plugin.arcus.ServiceCodeAccessor in project pinpoint by naver.
the class ApiInterceptor 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 SpanEventRecorder recorder = trace.currentSpanEventRecorder();
if (traceKey) {
final Object recordObject = args[keyIndex];
recorder.recordApi(methodDescriptor, recordObject, keyIndex);
} else {
recorder.recordApi(methodDescriptor);
}
recorder.recordException(throwable);
// find the target node
if (result instanceof Future && result instanceof OperationAccessor) {
final Operation op = ((OperationAccessor) result)._$PINPOINT$_getOperation();
if (op != null) {
final MemcachedNode handlingNode = op.getHandlingNode();
if (handlingNode != null) {
final String endPoint = getEndPoint(handlingNode);
if (endPoint != null) {
recorder.recordEndPoint(endPoint);
}
}
} else {
logger.info("operation not found");
}
}
if (target instanceof ServiceCodeAccessor) {
// determine the service type
String serviceCode = ((ServiceCodeAccessor) target)._$PINPOINT$_getServiceCode();
if (serviceCode != null) {
recorder.recordDestinationId(serviceCode);
recorder.recordServiceType(ArcusConstants.ARCUS);
} else {
recorder.recordDestinationId("MEMCACHED");
recorder.recordServiceType(ArcusConstants.MEMCACHED);
}
} else {
recorder.recordDestinationId("MEMCACHED");
recorder.recordServiceType(ArcusConstants.MEMCACHED);
}
try {
if (isAsynchronousInvocation(target, args, result, throwable)) {
// set asynchronous trace
this.traceContext.getAsyncId();
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
// type check isAsynchronousInvocation
((AsyncTraceIdAccessor) result)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
}
} finally {
trace.traceBlockEnd();
}
}
Aggregations