Search in sources :

Example 1 with VertxHttpClientRequestWrapper

use of com.navercorp.pinpoint.plugin.vertx.VertxHttpClientRequestWrapper 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();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) HttpRequest(io.netty.handler.codec.http.HttpRequest) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) ClientRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper) VertxHttpClientRequestWrapper(com.navercorp.pinpoint.plugin.vertx.VertxHttpClientRequestWrapper) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) VertxHttpClientRequestWrapper(com.navercorp.pinpoint.plugin.vertx.VertxHttpClientRequestWrapper)

Example 2 with VertxHttpClientRequestWrapper

use of com.navercorp.pinpoint.plugin.vertx.VertxHttpClientRequestWrapper 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();
    }
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) ClientRequestWrapper(com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper) VertxHttpClientRequestWrapper(com.navercorp.pinpoint.plugin.vertx.VertxHttpClientRequestWrapper) VertxHttpClientRequestWrapper(com.navercorp.pinpoint.plugin.vertx.VertxHttpClientRequestWrapper)

Aggregations

ClientRequestWrapper (com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper)2 VertxHttpClientRequestWrapper (com.navercorp.pinpoint.plugin.vertx.VertxHttpClientRequestWrapper)2 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)2 HttpRequest (io.netty.handler.codec.http.HttpRequest)2 SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)1