From 2ef2721f8a74181ca665c229be896aaf99f23f1e Mon Sep 17 00:00:00 2001 From: buildmaster Date: Tue, 18 Apr 2017 13:00:27 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- spring-cloud-sleuth.html | 51 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/spring-cloud-sleuth.html b/spring-cloud-sleuth.html index 07e6a86e1..3a4e7772e 100644 --- a/spring-cloud-sleuth.html +++ b/spring-cloud-sleuth.html @@ -521,7 +521,11 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • HTTP client integration
  • Feign
  • @@ -2771,6 +2775,51 @@ public static class TestConfiguration { To disable creation of the default TraceAsyncClientHttpRequestFactoryWrapper set spring.sleuth.web.async.client.factory.enabled to false. If you don’t want to create AsyncRestClient at all set spring.sleuth.web.async.client.template.enabled to false.

    +
    +
    Multiple Asynchronous Rest Templates
    +
    +

    Sometimes you need to use multiple implementations of Asynchronous Rest Template. In the following snippet you +can see an example of how to set up such a custom AsyncRestTemplate.

    +
    +
    +
    +
    @Configuration
    +@EnableAutoConfiguration
    +static class Config {
    +	@Autowired Tracer tracer;
    +	@Autowired HttpTraceKeysInjector httpTraceKeysInjector;
    +	@Autowired HttpSpanInjector spanInjector;
    +
    +	@Bean(name = "customAsyncRestTemplate")
    +	public AsyncRestTemplate traceAsyncRestTemplate(@Qualifier("customHttpRequestFactoryWrapper")
    +			TraceAsyncClientHttpRequestFactoryWrapper wrapper) {
    +		return new TraceAsyncRestTemplate(wrapper, this.tracer);
    +	}
    +
    +	@Bean(name = "customHttpRequestFactoryWrapper")
    +	public TraceAsyncClientHttpRequestFactoryWrapper traceAsyncClientHttpRequestFactory() {
    +		return new TraceAsyncClientHttpRequestFactoryWrapper(this.tracer,
    +				this.spanInjector,
    +				asyncClientFactory(),
    +				clientHttpRequestFactory(),
    +				this.httpTraceKeysInjector);
    +	}
    +
    +	private ClientHttpRequestFactory clientHttpRequestFactory() {
    +		ClientHttpRequestFactory clientHttpRequestFactory = new CustomClientHttpRequestFactory();
    +		//CUSTOMIZE HERE
    +		return clientHttpRequestFactory;
    +	}
    +
    +	private AsyncClientHttpRequestFactory asyncClientFactory() {
    +		AsyncClientHttpRequestFactory factory = new CustomAsyncClientHttpRequestFactory();
    +		//CUSTOMIZE HERE
    +		return factory;
    +	}
    +}
    +
    +
    +