use of brave.spring.web.TracingClientHttpRequestInterceptor.HttpRequestWrapper in project brave by openzipkin.
the class TracingAsyncClientHttpRequestInterceptor method intercept.
@Override
public ListenableFuture<ClientHttpResponse> intercept(HttpRequest req, byte[] body, AsyncClientHttpRequestExecution execution) throws IOException {
HttpRequestWrapper request = new HttpRequestWrapper(req);
Span span = handler.handleSend(request);
// avoid context sync overhead when we are the root span
TraceContext invocationContext = span.context().parentIdAsLong() != 0 ? currentTraceContext.get() : null;
try (Scope ws = currentTraceContext.maybeScope(span.context())) {
ListenableFuture<ClientHttpResponse> result = execution.executeAsync(req, body);
result.addCallback(new TraceListenableFutureCallback(request, span, handler));
return invocationContext != null ? new TraceContextListenableFuture<>(result, currentTraceContext, invocationContext) : result;
} catch (Throwable e) {
handler.handleReceive(new ClientHttpResponseWrapper(request, null, e), span);
throw e;
}
}
use of brave.spring.web.TracingClientHttpRequestInterceptor.HttpRequestWrapper in project brave by openzipkin.
the class HttpRequestWrapperTest method path_emptyToSlash.
// NOTE: While technically possible, it is not easy to make URI.getPath() return null!
@Test
public void path_emptyToSlash() {
when(request.getURI()).thenReturn(URI.create("http://localhost"));
assertThat(new HttpRequestWrapper(request).path()).isEqualTo("/");
}
use of brave.spring.web.TracingClientHttpRequestInterceptor.HttpRequestWrapper in project brave by openzipkin.
the class HttpRequestWrapperTest method path.
@Test
public void path() {
when(request.getURI()).thenReturn(URI.create("http://localhost/api"));
assertThat(new HttpRequestWrapper(request).path()).isEqualTo("/api");
}
Aggregations