use of com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor in project pinpoint by naver.
the class HttpRequestExecuteAsyncMethodInnerClassConstructorInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
if (!validate(target, args)) {
return;
}
final InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
if (transaction != null && transaction.getAttachment() != null) {
final AsyncTraceId asyncTraceId = (AsyncTraceId) transaction.getAttachment();
// type check validate();
((AsyncTraceIdAccessor) target)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
// clear.
transaction.removeAttachment();
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor in project pinpoint by naver.
the class TAsyncClientManagerCallInterceptor method injectAsyncTraceId.
private AsyncTraceId injectAsyncTraceId(final Object asyncMethodCallObj, final Trace trace) {
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
((AsyncTraceIdAccessor) asyncMethodCallObj)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
return asyncTraceId;
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor in project pinpoint by naver.
the class RequestStartAsyncInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, "", descriptor.getMethodName(), "", args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
if (validate(target, result, throwable)) {
((AsyncAccessor) target)._$PINPOINT$_setAsync(Boolean.TRUE);
// make asynchronous trace-id
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
// result is BasicFuture
// type check validate()
((AsyncTraceIdAccessor) result)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
}
recorder.recordServiceType(TomcatConstants.TOMCAT_METHOD);
recorder.recordApi(descriptor);
recorder.recordException(throwable);
} catch (Throwable t) {
logger.warn("Failed to AFTER process. {}", t.getMessage(), t);
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor in project pinpoint by naver.
the class HttpClientImplDoRequestInterceptor 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;
}
HttpClientRequest request = null;
if (validate(result)) {
request = (HttpClientRequest) result;
}
if (!trace.canSampled()) {
if (request != null) {
request.putHeader(Header.HTTP_SAMPLED.toString(), SamplingFlagUtils.SAMPLING_RATE_FALSE);
}
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT_INTERNAL);
if (request != null) {
// make asynchronous trace-id
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
((AsyncTraceIdAccessor) request)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncTraceIdAccessor in project pinpoint by naver.
the class HttpClientRequestImplDoHandleResponseInterceptor method doInBeforeTrace.
@Override
public void doInBeforeTrace(SpanEventRecorder recorder, AsyncTraceId asyncTraceId, Object target, Object[] args) {
if (!validate(args)) {
return;
}
final HttpClientResponseImpl response = (HttpClientResponseImpl) args[0];
if (statusCode) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, response.statusCode());
}
((AsyncTraceIdAccessor) response)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
}
Aggregations