From 50c81da505df08ec86e5c1cfec0e741590fe659f Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 4 Apr 2018 17:09:05 +0200 Subject: [PATCH] Added docs related to customization of zipkin rest template; fixes gh-924 --- .../main/asciidoc/spring-cloud-sleuth.adoc | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/src/main/asciidoc/spring-cloud-sleuth.adoc b/docs/src/main/asciidoc/spring-cloud-sleuth.adoc index 0f2dc64e3..c25835e15 100644 --- a/docs/src/main/asciidoc/spring-cloud-sleuth.adoc +++ b/docs/src/main/asciidoc/spring-cloud-sleuth.adoc @@ -548,6 +548,37 @@ Example for `web`: spring.zipkin.sender.type: web ---- +To customize the `RestTemplate` that sends spans to Zipkin via HTTP, you can register +the `ZipkinRestTemplateCustomizer` bean. + +[source,java] +---- +@Configuration +class MyConfig { + @Bean ZipkinRestTemplateCustomizer myCustomizer() { + return new ZipkinRestTemplateCustomizer() { + @Override + void customize(RestTemplate restTemplate) { + // customize the RestTemplate + } + }; + } +} +---- + +If, however, you would like to control the full process of creating the `RestTemplate` +object, you will have to create a bean of `zipkin2.reporter.Sender` type. + +[source,java] +---- + @Bean Sender myRestTemplateSender(ZipkinProperties zipkin, + ZipkinRestTemplateCustomizer zipkinRestTemplateCustomizer) { + RestTemplate restTemplate = mySuperCustomRestTemplate(); + zipkinRestTemplateCustomizer.customize(restTemplate); + return new RestTemplateSender(restTemplate, zipkin.getBaseUrl(), zipkin.getEncoder()); + } +---- + == Span Data as Messages You can accumulate and send span data over