|
|
@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.actuate.metrics.AutoTimer;
|
|
|
|
import org.springframework.boot.actuate.metrics.AutoTimer;
|
|
|
|
|
|
|
|
import org.springframework.boot.web.client.RootUriTemplateHandler;
|
|
|
|
import org.springframework.core.NamedThreadLocal;
|
|
|
|
import org.springframework.core.NamedThreadLocal;
|
|
|
|
import org.springframework.http.HttpRequest;
|
|
|
|
import org.springframework.http.HttpRequest;
|
|
|
|
import org.springframework.http.client.ClientHttpRequestExecution;
|
|
|
|
import org.springframework.http.client.ClientHttpRequestExecution;
|
|
|
@ -100,21 +101,10 @@ class MetricsClientHttpRequestInterceptor implements ClientHttpRequestIntercepto
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UriTemplateHandler createUriTemplateHandler(UriTemplateHandler delegate) {
|
|
|
|
UriTemplateHandler createUriTemplateHandler(UriTemplateHandler delegate) {
|
|
|
|
return new UriTemplateHandler() {
|
|
|
|
if (delegate instanceof RootUriTemplateHandler) {
|
|
|
|
|
|
|
|
return ((RootUriTemplateHandler) delegate).withHandlerWrapper(CapturingUriTemplateHandler::new);
|
|
|
|
@Override
|
|
|
|
}
|
|
|
|
public URI expand(String url, Map<String, ?> arguments) {
|
|
|
|
return new CapturingUriTemplateHandler(delegate);
|
|
|
|
urlTemplate.get().push(url);
|
|
|
|
|
|
|
|
return delegate.expand(url, arguments);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public URI expand(String url, Object... arguments) {
|
|
|
|
|
|
|
|
urlTemplate.get().push(url);
|
|
|
|
|
|
|
|
return delegate.expand(url, arguments);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Timer.Builder getTimeBuilder(HttpRequest request, ClientHttpResponse response) {
|
|
|
|
private Timer.Builder getTimeBuilder(HttpRequest request, ClientHttpResponse response) {
|
|
|
@ -123,6 +113,28 @@ class MetricsClientHttpRequestInterceptor implements ClientHttpRequestIntercepto
|
|
|
|
.description("Timer of RestTemplate operation");
|
|
|
|
.description("Timer of RestTemplate operation");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final class CapturingUriTemplateHandler implements UriTemplateHandler {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final UriTemplateHandler delegate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private CapturingUriTemplateHandler(UriTemplateHandler delegate) {
|
|
|
|
|
|
|
|
this.delegate = delegate;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public URI expand(String url, Map<String, ?> arguments) {
|
|
|
|
|
|
|
|
urlTemplate.get().push(url);
|
|
|
|
|
|
|
|
return this.delegate.expand(url, arguments);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public URI expand(String url, Object... arguments) {
|
|
|
|
|
|
|
|
urlTemplate.get().push(url);
|
|
|
|
|
|
|
|
return this.delegate.expand(url, arguments);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static final class UrlTemplateThreadLocal extends NamedThreadLocal<Deque<String>> {
|
|
|
|
private static final class UrlTemplateThreadLocal extends NamedThreadLocal<Deque<String>> {
|
|
|
|
|
|
|
|
|
|
|
|
private UrlTemplateThreadLocal() {
|
|
|
|
private UrlTemplateThreadLocal() {
|
|
|
|