use of com.navercorp.pinpoint.plugin.httpclient4.HttpCallContext 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;
// }
final InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
final Object attachment = getAttachment(transaction);
if (attachment instanceof HttpCallContext) {
return false;
}
return true;
}
use of com.navercorp.pinpoint.plugin.httpclient4.HttpCallContext in project pinpoint by naver.
the class HttpRequestExecutorDoSendRequestAndDoReceiveResponseMethodInterceptor 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 InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
final Object attachment = getAttachment(invocation);
if (attachment instanceof HttpCallContext) {
HttpCallContext callContext = (HttpCallContext) attachment;
if (methodDescriptor.getMethodName().equals("doSendRequest")) {
callContext.setWriteBeginTime(System.currentTimeMillis());
} else {
callContext.setReadBeginTime(System.currentTimeMillis());
}
if (isDebug) {
logger.debug("Set call context {}", callContext);
}
}
}
use of com.navercorp.pinpoint.plugin.httpclient4.HttpCallContext in project pinpoint by naver.
the class HttpRequestExecutorExecuteMethodInterceptor 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();
final HttpRequest httpRequest = getHttpRequest(args);
final NameIntValuePair<String> host = getHost();
if (httpRequest != null) {
ClientRequestWrapper clientRequest = new HttpClient4RequestWrapper(httpRequest, host.getName(), host.getValue());
this.clientRequestRecorder.record(recorder, clientRequest, throwable);
this.cookieRecorder.record(recorder, httpRequest, throwable);
}
if (statusCode) {
final Integer statusCodeValue = getStatusCode(result);
if (statusCodeValue != null) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, statusCodeValue);
}
recordResponseHeader(recorder, result);
}
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
final Object attachment = getAttachment(invocation);
if (attachment instanceof HttpCallContext) {
final HttpCallContext callContext = (HttpCallContext) attachment;
logger.debug("Check call context {}", callContext);
if (io) {
final IntBooleanIntBooleanValue value = new IntBooleanIntBooleanValue((int) callContext.getWriteElapsedTime(), callContext.isWriteFail(), (int) callContext.getReadElapsedTime(), callContext.isReadFail());
recorder.recordAttribute(AnnotationKey.HTTP_IO, value);
}
// clear
invocation.removeAttachment();
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.plugin.httpclient4.HttpCallContext in project pinpoint by naver.
the class HttpRequestExecutorExecuteMethodInterceptor method getHost.
private NameIntValuePair<String> getHost() {
final InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
final Object attachment = getAttachment(transaction);
if (attachment instanceof HttpCallContext) {
HttpCallContext callContext = (HttpCallContext) attachment;
return new NameIntValuePair<>(callContext.getHost(), callContext.getPort());
}
return new NameIntValuePair<>(null, -1);
}
use of com.navercorp.pinpoint.plugin.httpclient4.HttpCallContext 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());
}
}
}
Aggregations