use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class AbstractHttpClientExecuteMethodInterceptor 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;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(HttpClient4Constants.HTTP_CLIENT_4_INTERNAL);
final NameIntValuePair<String> host = getHost(args);
if (host != null) {
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null) {
final HttpCallContext callContext = (HttpCallContext) invocation.getOrCreateAttachment(HttpCallContextFactory.HTTPCALL_CONTEXT_FACTORY);
callContext.setHost(host.getName());
callContext.setPort(host.getValue());
}
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class AbstractHttpClientExecuteMethodInterceptor 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;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null) {
// clear
invocation.removeAttachment();
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class HttpClientExecuteMethodInternalInterceptor method needGetStatusCode.
private boolean needGetStatusCode() {
if (isHasCallbackParam) {
return false;
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return false;
}
// TODO fix me.
// if (trace.getServiceType() != ServiceType.ASYNC_HTTP_CLIENT.getCode()) {
// return false;
// }
InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
if (transaction != null && transaction.getAttachment() != null && transaction.getAttachment() instanceof HttpCallContext) {
return false;
}
return true;
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class HttpMethodBaseRequestAndResponseMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, methodDescriptor.getClassName(), methodDescriptor.getMethodName(), "", args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null && invocation.getAttachment() != null && invocation.getAttachment() instanceof HttpClient3CallContext) {
HttpClient3CallContext callContext = (HttpClient3CallContext) invocation.getAttachment();
if (methodDescriptor.getMethodName().equals("writeRequest")) {
callContext.setWriteBeginTime(System.currentTimeMillis());
} else {
callContext.setReadBeginTime(System.currentTimeMillis());
}
logger.debug("Set call context {}", callContext);
}
}
use of com.navercorp.pinpoint.bootstrap.interceptor.scope.InterceptorScopeInvocation in project pinpoint by naver.
the class HttpRequestExecuteAsyncMethodInterceptor 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;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
try {
// set asynchronous trace
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
// set async id.
InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
if (transaction != null) {
transaction.setAttachment(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
}
} catch (Throwable t) {
logger.warn("Failed to before process. {}", t.getMessage(), t);
}
}
Aggregations