use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class HttpClientImplDoRequestInterceptorV4 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;
}
if (!trace.canSampled()) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT_INTERNAL);
final String hostAndPort = toHostAndPort(args);
if (hostAndPort != null) {
recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, hostAndPort);
if (isDebug) {
logger.debug("Set hostAndPort {}", hostAndPort);
}
}
if (target instanceof AsyncContextAccessor) {
// make asynchronous trace-id
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class HttpClientRequestImplConstructorInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
if (ArrayUtils.getLength(args) < 1) {
return;
}
final Object arg = args[0];
final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(arg);
if (asyncContext != null) {
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
}
if (arg instanceof SamplingRateFlag) {
final Boolean samplingRateFlag = ((SamplingRateFlag) (args[0]))._$PINPOINT$_getSamplingRateFlag();
((SamplingRateFlag) target)._$PINPOINT$_setSamplingRateFlag(samplingRateFlag);
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class AsyncContextTest method testClose.
@Test
public void testClose() {
AsyncContext asyncContext = newAsyncContext(true);
// invoke continueTraceObject
Trace trace = asyncContext.continueAsyncTraceObject();
assertNotNull(trace);
// close
asyncContext.close();
assertNull(asyncContext.currentAsyncTraceObject());
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class AsyncContextTest method testAsyncTraceObject.
@Test
public void testAsyncTraceObject() {
AsyncContext enabledAsyncContext = newAsyncContext(true);
AsyncContext disabledAsyncContext = newAsyncContext(false);
// at first, trace object must be null
assertNull(enabledAsyncContext.currentAsyncTraceObject());
assertNull(disabledAsyncContext.currentAsyncTraceObject());
// invoke continueTraceObject
Trace enabledTrace = enabledAsyncContext.continueAsyncTraceObject();
Trace disabledTrace = disabledAsyncContext.continueAsyncTraceObject();
assertTrue(enabledTrace instanceof AsyncChildTrace);
assertNull(disabledTrace);
// check current trace object
assertEquals(enabledTrace, enabledAsyncContext.currentAsyncTraceObject());
assertNull(disabledAsyncContext.currentAsyncTraceObject());
// re-invocation of continueTraceObject must not change trace object
Trace anotherEnabledTrace = enabledAsyncContext.continueAsyncTraceObject();
assertEquals(enabledTrace, anotherEnabledTrace);
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class MongoRSessionInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
if (collectJson) {
final boolean success = InterceptorUtils.isSuccess(throwable);
if (success) {
if (args != null) {
NormalizedBson parsedBson = MongoUtil.parseBson(args, traceBsonBindValue);
MongoUtil.recordParsedBson(recorder, parsedBson);
}
}
}
recorder.recordException(throwable);
if (isAsynchronousInvocation(target, args, result, throwable)) {
// Trace to Disposable object
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set AsyncContext {}, result={}", asyncContext, result);
}
}
}
Aggregations