use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class DefaultScopeTest method testAttachment3.
@Test
public void testAttachment3() {
String oldAttachment = "context";
String newAttachment = "newnew";
InterceptorScopeInvocation transaction = new DefaultInterceptorScopeInvocation("test");
transaction.tryEnter(ExecutionPolicy.ALWAYS);
transaction.setAttachment(oldAttachment);
assertSame(oldAttachment, transaction.getAttachment());
assertSame(oldAttachment, transaction.setAttachment(newAttachment));
assertSame(newAttachment, transaction.getAttachment());
assertSame(newAttachment, transaction.removeAttachment());
assertNull(transaction.getAttachment());
transaction.canLeave(ExecutionPolicy.ALWAYS);
transaction.leave(ExecutionPolicy.ALWAYS);
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class DefaultScopeTest method testAfterWithoutBefore3.
@Test(expected = IllegalStateException.class)
public void testAfterWithoutBefore3() {
InterceptorScopeInvocation transaction = new DefaultInterceptorScopeInvocation("test");
transaction.leave(ExecutionPolicy.INTERNAL);
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class DefaultScopeTest method testSetAttachmentFail2.
@Test(expected = IllegalStateException.class)
public void testSetAttachmentFail2() {
InterceptorScopeInvocation transaction = new DefaultInterceptorScopeInvocation("test");
transaction.tryEnter(ExecutionPolicy.ALWAYS);
transaction.canLeave(ExecutionPolicy.ALWAYS);
transaction.leave(ExecutionPolicy.ALWAYS);
transaction.setAttachment("attachment");
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class HttpRequestExecutorDoSendRequestAndDoReceiveResponseMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null && invocation.getAttachment() != null && invocation.getAttachment() instanceof HttpCallContext) {
HttpCallContext callContext = (HttpCallContext) invocation.getAttachment();
if (methodDescriptor.getMethodName().equals("doSendRequest")) {
callContext.setWriteEndTime(System.currentTimeMillis());
callContext.setWriteFail(throwable != null);
} else {
callContext.setReadEndTime(System.currentTimeMillis());
callContext.setReadFail(throwable != null);
}
if (isDebug) {
logger.debug("Set call context {}", callContext);
}
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class HttpClientExecuteMethodInternalInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, target.getClass().getName(), "", "internal", args);
}
if (!needGetStatusCode()) {
return;
}
if (result != null && result instanceof HttpResponse) {
HttpResponse response = (HttpResponse) result;
if (response.getStatusLine() != null) {
HttpCallContext context = new HttpCallContext();
final StatusLine statusLine = response.getStatusLine();
if (statusLine != null) {
context.setStatusCode(statusLine.getStatusCode());
InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
if (transaction != null && transaction.getAttachment() == null) {
transaction.setAttachment(context);
}
}
}
}
}
Aggregations