use of com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper 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.bootstrap.plugin.request.ClientRequestWrapper in project pinpoint by naver.
the class Http1xClientConnectionCreateRequestInterceptor 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()) {
if (result instanceof HttpRequest) {
final HttpRequest request = (HttpRequest) result;
requestTraceWriter.write(request);
}
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT);
if (!validate(args, result)) {
return;
}
final HttpRequest request = (HttpRequest) result;
final HttpHeaders headers = request.headers();
if (headers == null) {
return;
}
String host = ArrayArgumentUtils.getArgument(args, 4, String.class, "UNKNOWN");
// generate next trace id.
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
requestTraceWriter.write(request, nextId, host);
final ClientRequestWrapper clientRequest = new VertxHttpClientRequestWrapper(request, host);
this.clientRequestRecorder.record(recorder, clientRequest, throwable);
this.cookieRecorder.record(recorder, request, throwable);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", t.getMessage(), t);
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper in project pinpoint by naver.
the class HttpClientStreamInterceptor 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;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT);
if (!validate(args)) {
return;
}
final HttpRequest request = (HttpRequest) args[0];
final HttpHeaders headers = request.headers();
if (headers == null) {
return;
}
final String host = (String) args[1];
ClientRequestWrapper clientRequest = new VertxHttpClientRequestWrapper(request, host);
this.clientRequestRecorder.record(recorder, clientRequest, throwable);
this.cookieRecorder.record(recorder, request, throwable);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", t.getMessage(), t);
}
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper in project pinpoint by naver.
the class BodyInserterRequestBuilderWriteToInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
if (!validate(args)) {
return;
}
final ClientHttpRequest request = (ClientHttpRequest) args[0];
final ClientRequestWrapper clientRequestWrapper = new WebClientRequestWrapper(request);
this.clientRequestRecorder.record(recorder, clientRequestWrapper, throwable);
this.cookieRecorder.record(recorder, request, throwable);
if (isAsync(result)) {
// make asynchronous trace-id
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set closeable-AsyncContext {}", asyncContext);
}
}
}
use of com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper in project pinpoint by naver.
the class HttpClientOperationsSendInterceptor method doInBeforeTrace.
@Override
public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) {
final Trace trace = asyncContext.currentAsyncTraceObject();
if (trace == null) {
if (logger.isWarnEnabled()) {
logger.warn("Unexpected error, Current async trace is null");
}
return;
}
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(ReactorNettyConstants.REACTOR_NETTY_CLIENT);
final HttpClientRequest request = (HttpClientRequest) target;
final ClientRequestWrapper clientRequestWrapper = new HttpClientRequestWrapper(request);
this.requestTraceWriter.write(request, nextId, clientRequestWrapper.getDestinationId());
}
Aggregations