Search in sources :

Example 41 with HttpException

use of org.apache.http.HttpException in project jaeger-client-java by jaegertracing.

the class TracingRequestInterceptor method process.

@Override
public void process(HttpRequest httpRequest, HttpContext httpContext) throws HttpException, IOException {
    try {
        spanCreationInterceptor.process(httpRequest, httpContext);
        Scope currentScope = tracer.scopeManager().active();
        if (currentScope != null) {
            onSpanStarted(currentScope.span(), httpRequest, httpContext);
        } else {
            log.warn("Current scope is null; possibly failed to start client tracing span.");
        }
        spanInjectionInterceptor.process(httpRequest, httpContext);
    } catch (Exception e) {
        log.error("Could not start client tracing span.", e);
    }
}
Also used : Scope(io.opentracing.Scope) HttpException(org.apache.http.HttpException) IOException(java.io.IOException)

Example 42 with HttpException

use of org.apache.http.HttpException in project jaeger-client-java by jaegertracing.

the class TracingResponseInterceptor method process.

@Override
public void process(HttpResponse httpResponse, HttpContext httpContext) throws HttpException, IOException {
    try {
        Span clientSpan = (Span) httpContext.getAttribute(Constants.CURRENT_SPAN_CONTEXT_KEY);
        if (clientSpan != null) {
            Tags.HTTP_STATUS.set(clientSpan, httpResponse.getStatusLine().getStatusCode());
            beforeSpanFinish(clientSpan, httpResponse, httpContext);
            clientSpan.finish();
        } else {
            log.warn("The ResponseInterceptor did not find a clientSpan. " + "Verify that the RequestInterceptor is correctly set up.");
        }
    } catch (Exception e) {
        log.error("Could not finish client tracing span.", e);
    }
}
Also used : Span(io.opentracing.Span) HttpException(org.apache.http.HttpException) IOException(java.io.IOException)

Aggregations

HttpException (org.apache.http.HttpException)42 IOException (java.io.IOException)27 HttpRequest (org.apache.http.HttpRequest)22 HttpResponse (org.apache.http.HttpResponse)21 HttpHost (org.apache.http.HttpHost)13 HttpContext (org.apache.http.protocol.HttpContext)13 HttpEntity (org.apache.http.HttpEntity)12 Header (org.apache.http.Header)11 BasicHttpRequest (org.apache.http.message.BasicHttpRequest)11 AbortableHttpRequest (org.apache.http.client.methods.AbortableHttpRequest)8 BufferedHttpEntity (org.apache.http.entity.BufferedHttpEntity)8 HttpRequestHandler (org.apache.http.protocol.HttpRequestHandler)7 ParseException (org.apache.http.ParseException)6 ProtocolVersion (org.apache.http.ProtocolVersion)6 CredentialsProvider (org.apache.http.client.CredentialsProvider)6 StringEntity (org.apache.http.entity.StringEntity)6 AuthenticationException (org.apache.http.auth.AuthenticationException)5 Before (org.junit.Before)5 InterruptedIOException (java.io.InterruptedIOException)4 Socket (java.net.Socket)4