Sync docs from master to gh-pages
This commit is contained in:
@@ -126,74 +126,81 @@ $(globalSwitch);
|
||||
<li><a href="#log-correlation">2.2. Log correlation</a></li>
|
||||
<li><a href="#service-dependency-graph">2.3. Service Dependency Graph</a></li>
|
||||
<li><a href="#request-scoped-properties-baggage">2.4. Request scoped properties (Baggage)</a></li>
|
||||
<li><a href="#sleuth-adding-project">2.5. Adding Sleuth to the Project</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#how-sleuth-works">3. How Sleuth works</a>
|
||||
<li><a href="#sleuth-adding-project">3. Adding Sleuth to your Project</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#brave-basics">3.1. Brave Basics</a></li>
|
||||
<li><a href="#sleuth-with-zipkin-via-http">3.1. Sleuth with Zipkin via HTTP</a></li>
|
||||
<li><a href="#sleuth-with-zipkin-over-rabbitmq-or-kafka">3.2. Sleuth with Zipkin over RabbitMQ or Kafka</a></li>
|
||||
<li><a href="#overriding-the-auto-configuration-of-zipkin">3.3. Overriding the auto-configuration of Zipkin</a></li>
|
||||
<li><a href="#only-sleuth-log-correlation">3.4. Only Sleuth (log correlation)</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#sampling">4. Sampling</a></li>
|
||||
<li><a href="#baggage">5. Baggage</a>
|
||||
<li><a href="#how-sleuth-works">4. How Sleuth works</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#java-configuration">5.1. Java configuration</a></li>
|
||||
<li><a href="#brave-basics">4.1. Brave Basics</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#instrumentation">6. Instrumentation</a></li>
|
||||
<li><a href="#span-lifecycle">7. Span lifecycle</a>
|
||||
<li><a href="#sampling">5. Sampling</a></li>
|
||||
<li><a href="#baggage">6. Baggage</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#creating-and-finishing-spans">7.1. Creating and finishing spans</a></li>
|
||||
<li><a href="#continuing-spans">7.2. Continuing Spans</a></li>
|
||||
<li><a href="#creating-spans-with-explicit-parent">7.3. Creating a Span with an explicit Parent</a></li>
|
||||
<li><a href="#java-configuration">6.1. Java configuration</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#naming-spans">8. Naming spans</a>
|
||||
<li><a href="#instrumentation">7. Instrumentation</a></li>
|
||||
<li><a href="#span-lifecycle">8. Span lifecycle</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#spanname-annotation">8.1. <code>@SpanName</code> Annotation</a></li>
|
||||
<li><a href="#tostring-method">8.2. <code>toString()</code> method</a></li>
|
||||
<li><a href="#creating-and-finishing-spans">8.1. Creating and finishing spans</a></li>
|
||||
<li><a href="#continuing-spans">8.2. Continuing Spans</a></li>
|
||||
<li><a href="#creating-spans-with-explicit-parent">8.3. Creating a Span with an explicit Parent</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#managing-spans-with-annotations">9. Managing Spans with Annotations</a>
|
||||
<li><a href="#naming-spans">9. Naming spans</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#rationale">9.1. Rationale</a></li>
|
||||
<li><a href="#creating-new-spans">9.2. Creating New Spans</a></li>
|
||||
<li><a href="#continuing-spans-2">9.3. Continuing Spans</a></li>
|
||||
<li><a href="#advanced-tag-setting">9.4. Advanced Tag Setting</a></li>
|
||||
<li><a href="#spanname-annotation">9.1. <code>@SpanName</code> Annotation</a></li>
|
||||
<li><a href="#tostring-method">9.2. <code>toString()</code> method</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#customizations">10. Customizations</a>
|
||||
<li><a href="#managing-spans-with-annotations">10. Managing Spans with Annotations</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#http">10.1. HTTP</a></li>
|
||||
<li><a href="#tracingfilter">10.2. <code>TracingFilter</code></a></li>
|
||||
<li><a href="#messaging">10.3. Messaging</a></li>
|
||||
<li><a href="#rpc">10.4. RPC</a></li>
|
||||
<li><a href="#custom-service-name">10.5. Custom service name</a></li>
|
||||
<li><a href="#customization-of-reported-spans">10.6. Customization of Reported Spans</a></li>
|
||||
<li><a href="#host-locator">10.7. Host Locator</a></li>
|
||||
<li><a href="#rationale">10.1. Rationale</a></li>
|
||||
<li><a href="#creating-new-spans">10.2. Creating New Spans</a></li>
|
||||
<li><a href="#continuing-spans-2">10.3. Continuing Spans</a></li>
|
||||
<li><a href="#advanced-tag-setting">10.4. Advanced Tag Setting</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#sending-spans-to-zipkin">11. Sending Spans to Zipkin</a></li>
|
||||
<li><a href="#zipkin-stream-span-consumer">12. Zipkin Stream Span Consumer</a></li>
|
||||
<li><a href="#integrations">13. Integrations</a>
|
||||
<li><a href="#customizations">11. Customizations</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#opentracing">13.1. OpenTracing</a></li>
|
||||
<li><a href="#runnable-and-callable">13.2. Runnable and Callable</a></li>
|
||||
<li><a href="#spring-cloud-circuitbreaker">13.3. Spring Cloud CircuitBreaker</a></li>
|
||||
<li><a href="#rxjava">13.4. RxJava</a></li>
|
||||
<li><a href="#http-integration">13.5. HTTP integration</a></li>
|
||||
<li><a href="#http-client-integration">13.6. HTTP Client Integration</a></li>
|
||||
<li><a href="#feign">13.7. Feign</a></li>
|
||||
<li><a href="#grpc">13.8. gRPC</a></li>
|
||||
<li><a href="#asynchronous-communication">13.9. Asynchronous Communication</a></li>
|
||||
<li><a href="#messaging-2">13.10. Messaging</a></li>
|
||||
<li><a href="#redis">13.11. Redis</a></li>
|
||||
<li><a href="#quartz">13.12. Quartz</a></li>
|
||||
<li><a href="#project-reactor">13.13. Project Reactor</a></li>
|
||||
<li><a href="#http">11.1. HTTP</a></li>
|
||||
<li><a href="#tracingfilter">11.2. <code>TracingFilter</code></a></li>
|
||||
<li><a href="#messaging">11.3. Messaging</a></li>
|
||||
<li><a href="#rpc">11.4. RPC</a></li>
|
||||
<li><a href="#custom-service-name">11.5. Custom service name</a></li>
|
||||
<li><a href="#customization-of-reported-spans">11.6. Customization of Reported Spans</a></li>
|
||||
<li><a href="#host-locator">11.7. Host Locator</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#configuration-properties">14. Configuration properties</a></li>
|
||||
<li><a href="#running-examples">15. Running examples</a></li>
|
||||
<li><a href="#sending-spans-to-zipkin">12. Sending Spans to Zipkin</a></li>
|
||||
<li><a href="#zipkin-stream-span-consumer">13. Zipkin Stream Span Consumer</a></li>
|
||||
<li><a href="#integrations">14. Integrations</a>
|
||||
<ul class="sectlevel2">
|
||||
<li><a href="#opentracing">14.1. OpenTracing</a></li>
|
||||
<li><a href="#runnable-and-callable">14.2. Runnable and Callable</a></li>
|
||||
<li><a href="#spring-cloud-circuitbreaker">14.3. Spring Cloud CircuitBreaker</a></li>
|
||||
<li><a href="#rxjava">14.4. RxJava</a></li>
|
||||
<li><a href="#http-integration">14.5. HTTP integration</a></li>
|
||||
<li><a href="#http-client-integration">14.6. HTTP Client Integration</a></li>
|
||||
<li><a href="#feign">14.7. Feign</a></li>
|
||||
<li><a href="#grpc">14.8. gRPC</a></li>
|
||||
<li><a href="#asynchronous-communication">14.9. Asynchronous Communication</a></li>
|
||||
<li><a href="#messaging-2">14.10. Messaging</a></li>
|
||||
<li><a href="#redis">14.11. Redis</a></li>
|
||||
<li><a href="#quartz">14.12. Quartz</a></li>
|
||||
<li><a href="#project-reactor">14.13. Project Reactor</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#configuration-properties">15. Configuration properties</a></li>
|
||||
<li><a href="#running-examples">16. Running examples</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -589,8 +596,11 @@ like so:</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="sleuth-adding-project"><a class="anchor" href="#sleuth-adding-project"></a><a class="link" href="#sleuth-adding-project">2.5. Adding Sleuth to the Project</a></h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="sleuth-adding-project"><a class="anchor" href="#sleuth-adding-project"></a><a class="link" href="#sleuth-adding-project">3. Adding Sleuth to your Project</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>This section addresses how to add Sleuth to your project with either Maven or Gradle.</p>
|
||||
</div>
|
||||
@@ -606,8 +616,8 @@ To ensure that your application name is properly displayed in Zipkin, set the <c
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="sleuth-with-zipkin-via-http"><a class="anchor" href="#sleuth-with-zipkin-via-http"></a><a class="link" href="#sleuth-with-zipkin-via-http">2.5.1. Sleuth with Zipkin via HTTP</a></h4>
|
||||
<div class="sect2">
|
||||
<h3 id="sleuth-with-zipkin-via-http"><a class="anchor" href="#sleuth-with-zipkin-via-http"></a><a class="link" href="#sleuth-with-zipkin-via-http">3.1. Sleuth with Zipkin via HTTP</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you want both Sleuth and Zipkin, add the <code>spring-cloud-starter-zipkin</code> dependency.</p>
|
||||
</div>
|
||||
@@ -677,8 +687,8 @@ dependencies { <i class="conum" data-value="2"></i><b>(2)</b>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="sleuth-with-zipkin-over-rabbitmq-or-kafka"><a class="anchor" href="#sleuth-with-zipkin-over-rabbitmq-or-kafka"></a><a class="link" href="#sleuth-with-zipkin-over-rabbitmq-or-kafka">2.5.2. Sleuth with Zipkin over RabbitMQ or Kafka</a></h4>
|
||||
<div class="sect2">
|
||||
<h3 id="sleuth-with-zipkin-over-rabbitmq-or-kafka"><a class="anchor" href="#sleuth-with-zipkin-over-rabbitmq-or-kafka"></a><a class="link" href="#sleuth-with-zipkin-over-rabbitmq-or-kafka">3.2. Sleuth with Zipkin over RabbitMQ or Kafka</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you want to use RabbitMQ or Kafka instead of HTTP, add the <code>spring-rabbit</code> or <code>spring-kafka</code> dependency.
|
||||
The default destination name is <code>zipkin</code>.</p>
|
||||
@@ -783,8 +793,8 @@ dependencies {
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="overriding-the-auto-configuration-of-zipkin"><a class="anchor" href="#overriding-the-auto-configuration-of-zipkin"></a><a class="link" href="#overriding-the-auto-configuration-of-zipkin">2.5.3. Overriding the auto-configuration of Zipkin</a></h4>
|
||||
<div class="sect2">
|
||||
<h3 id="overriding-the-auto-configuration-of-zipkin"><a class="anchor" href="#overriding-the-auto-configuration-of-zipkin"></a><a class="link" href="#overriding-the-auto-configuration-of-zipkin">3.3. Overriding the auto-configuration of Zipkin</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Sleuth supports sending traces to multiple tracing systems as of version 2.1.0.
|
||||
In order to get this to work, every tracing system needs to have a <code>Reporter<Span></code> and <code>Sender</code>.
|
||||
@@ -841,8 +851,8 @@ protected static class MyConfig {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="only-sleuth-log-correlation"><a class="anchor" href="#only-sleuth-log-correlation"></a><a class="link" href="#only-sleuth-log-correlation">2.5.4. Only Sleuth (log correlation)</a></h4>
|
||||
<div class="sect2">
|
||||
<h3 id="only-sleuth-log-correlation"><a class="anchor" href="#only-sleuth-log-correlation"></a><a class="link" href="#only-sleuth-log-correlation">3.4. Only Sleuth (log correlation)</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you want to use only Spring Cloud Sleuth without the Zipkin integration, add the <code>spring-cloud-starter-sleuth</code> module to your project.</p>
|
||||
</div>
|
||||
@@ -914,9 +924,8 @@ dependencies { <i class="conum" data-value="2"></i><b>(2)</b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="how-sleuth-works"><a class="anchor" href="#how-sleuth-works"></a><a class="link" href="#how-sleuth-works">3. How Sleuth works</a></h2>
|
||||
<h2 id="how-sleuth-works"><a class="anchor" href="#how-sleuth-works"></a><a class="link" href="#how-sleuth-works">4. How Sleuth works</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Sleuth is a layer over <a href="https://github.com/openzipkin/brave">Brave</a>.</p>
|
||||
@@ -957,7 +966,7 @@ looking for in the documentation, ask <a href="https://gitter.im/spring-cloud/sp
|
||||
before assuming something cannot be done.</p>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="brave-basics"><a class="anchor" href="#brave-basics"></a><a class="link" href="#brave-basics">3.1. Brave Basics</a></h3>
|
||||
<h3 id="brave-basics"><a class="anchor" href="#brave-basics"></a><a class="link" href="#brave-basics">4.1. Brave Basics</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Most instrumentation work is done for you by default. Sleuth provides beans to
|
||||
allow you to change what’s traced, and it even provides annotations to avoid
|
||||
@@ -982,7 +991,7 @@ are some pointers.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="sampling"><a class="anchor" href="#sampling"></a><a class="link" href="#sampling">4. Sampling</a></h2>
|
||||
<h2 id="sampling"><a class="anchor" href="#sampling"></a><a class="link" href="#sampling">5. Sampling</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>By default Spring Cloud Sleuth doesn’t sample spans.
|
||||
@@ -1033,7 +1042,7 @@ Doing so forces the current request to be sampled regardless of configuration.
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="baggage"><a class="anchor" href="#baggage"></a><a class="link" href="#baggage">5. Baggage</a></h2>
|
||||
<h2 id="baggage"><a class="anchor" href="#baggage"></a><a class="link" href="#baggage">6. Baggage</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Baggage are fields that are propagated with the trace, optionally out of process. You can use
|
||||
@@ -1078,7 +1087,7 @@ Remember that adding entries to MDC can drastically decrease the performance of
|
||||
<code>spring.sleuth.baggage.tag-fields</code> with a list of whitelisted baggage keys. To disable the feature you have to pass the <code>spring.sleuth.propagation.tag.enabled=false</code> property.</p>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="java-configuration"><a class="anchor" href="#java-configuration"></a><a class="link" href="#java-configuration">5.1. Java configuration</a></h3>
|
||||
<h3 id="java-configuration"><a class="anchor" href="#java-configuration"></a><a class="link" href="#java-configuration">6.1. Java configuration</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you need to do anything more advanced than above, do not define properties and instead use a
|
||||
<code>@Bean</code> config for the baggage fields you use.
|
||||
@@ -1091,7 +1100,7 @@ Remember that adding entries to MDC can drastically decrease the performance of
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="instrumentation"><a class="anchor" href="#instrumentation"></a><a class="link" href="#instrumentation">6. Instrumentation</a></h2>
|
||||
<h2 id="instrumentation"><a class="anchor" href="#instrumentation"></a><a class="link" href="#instrumentation">7. Instrumentation</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Sleuth automatically instruments all your Spring applications, so you should not have to do anything to activate it.
|
||||
@@ -1117,7 +1126,7 @@ Tags are collected and exported only if there is a <code>Sampler</code> that all
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="span-lifecycle"><a class="anchor" href="#span-lifecycle"></a><a class="link" href="#span-lifecycle">7. Span lifecycle</a></h2>
|
||||
<h2 id="span-lifecycle"><a class="anchor" href="#span-lifecycle"></a><a class="link" href="#span-lifecycle">8. Span lifecycle</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>You can do the following operations on the Span by means of <code>brave.Tracer</code>:</p>
|
||||
@@ -1156,7 +1165,7 @@ Spring Cloud Sleuth creates an instance of <code>Tracer</code> for you. In order
|
||||
</table>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="creating-and-finishing-spans"><a class="anchor" href="#creating-and-finishing-spans"></a><a class="link" href="#creating-and-finishing-spans">7.1. Creating and finishing spans</a></h3>
|
||||
<h3 id="creating-and-finishing-spans"><a class="anchor" href="#creating-and-finishing-spans"></a><a class="link" href="#creating-and-finishing-spans">8.1. Creating and finishing spans</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>You can manually create spans by using the <code>Tracer</code>, as shown in the following example:</p>
|
||||
</div>
|
||||
@@ -1211,7 +1220,7 @@ Your names have to be explicit and concrete. Big names lead to latency issues an
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="continuing-spans"><a class="anchor" href="#continuing-spans"></a><a class="link" href="#continuing-spans">7.2. Continuing Spans</a></h3>
|
||||
<h3 id="continuing-spans"><a class="anchor" href="#continuing-spans"></a><a class="link" href="#continuing-spans">8.2. Continuing Spans</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Sometimes, you do not want to create a new span but you want to continue one. An example of such a
|
||||
situation might be as follows:</p>
|
||||
@@ -1248,7 +1257,7 @@ finally {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="creating-spans-with-explicit-parent"><a class="anchor" href="#creating-spans-with-explicit-parent"></a><a class="link" href="#creating-spans-with-explicit-parent">7.3. Creating a Span with an explicit Parent</a></h3>
|
||||
<h3 id="creating-spans-with-explicit-parent"><a class="anchor" href="#creating-spans-with-explicit-parent"></a><a class="link" href="#creating-spans-with-explicit-parent">8.3. Creating a Span with an explicit Parent</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>You might want to start a new span and provide an explicit parent of that span.
|
||||
Assume that the parent of a span is in one thread and you want to start a new span in another thread.
|
||||
@@ -1296,7 +1305,7 @@ After creating such a span, you must finish it. Otherwise it is not reported (fo
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="naming-spans"><a class="anchor" href="#naming-spans"></a><a class="link" href="#naming-spans">8. Naming spans</a></h2>
|
||||
<h2 id="naming-spans"><a class="anchor" href="#naming-spans"></a><a class="link" href="#naming-spans">9. Naming spans</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Picking a span name is not a trivial task. A span name should depict an operation name.
|
||||
@@ -1322,7 +1331,7 @@ The name should be low cardinality, so it should not include identifiers.</p>
|
||||
<p>Fortunately, for asynchronous processing, you can provide explicit naming.</p>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="spanname-annotation"><a class="anchor" href="#spanname-annotation"></a><a class="link" href="#spanname-annotation">8.1. <code>@SpanName</code> Annotation</a></h3>
|
||||
<h3 id="spanname-annotation"><a class="anchor" href="#spanname-annotation"></a><a class="link" href="#spanname-annotation">9.1. <code>@SpanName</code> Annotation</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>You can name the span explicitly by using the <code>@SpanName</code> annotation, as shown in the following example:</p>
|
||||
</div>
|
||||
@@ -1353,7 +1362,7 @@ future.get();</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="tostring-method"><a class="anchor" href="#tostring-method"></a><a class="link" href="#tostring-method">8.2. <code>toString()</code> method</a></h3>
|
||||
<h3 id="tostring-method"><a class="anchor" href="#tostring-method"></a><a class="link" href="#tostring-method">9.2. <code>toString()</code> method</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>It is pretty rare to create separate classes for <code>Runnable</code> or <code>Callable</code>.
|
||||
Typically, one creates an anonymous instance of those classes.
|
||||
@@ -1385,13 +1394,13 @@ future.get();</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="managing-spans-with-annotations"><a class="anchor" href="#managing-spans-with-annotations"></a><a class="link" href="#managing-spans-with-annotations">9. Managing Spans with Annotations</a></h2>
|
||||
<h2 id="managing-spans-with-annotations"><a class="anchor" href="#managing-spans-with-annotations"></a><a class="link" href="#managing-spans-with-annotations">10. Managing Spans with Annotations</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>You can manage spans with a variety of annotations.</p>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="rationale"><a class="anchor" href="#rationale"></a><a class="link" href="#rationale">9.1. Rationale</a></h3>
|
||||
<h3 id="rationale"><a class="anchor" href="#rationale"></a><a class="link" href="#rationale">10.1. Rationale</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>There are a number of good reasons to manage spans with annotations, including:</p>
|
||||
</div>
|
||||
@@ -1414,7 +1423,7 @@ Now you can provide annotations over interfaces and the arguments of those inter
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="creating-new-spans"><a class="anchor" href="#creating-new-spans"></a><a class="link" href="#creating-new-spans">9.2. Creating New Spans</a></h3>
|
||||
<h3 id="creating-new-spans"><a class="anchor" href="#creating-new-spans"></a><a class="link" href="#creating-new-spans">10.2. Creating New Spans</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you do not want to create local spans manually, you can use the <code>@NewSpan</code> annotation.
|
||||
Also, we provide the <code>@SpanTag</code> annotation to add tags in an automated fashion.</p>
|
||||
@@ -1470,7 +1479,7 @@ concrete one wins (in this case <code>customNameOnTestMethod3</code> is set).</p
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="continuing-spans-2"><a class="anchor" href="#continuing-spans-2"></a><a class="link" href="#continuing-spans-2">9.3. Continuing Spans</a></h3>
|
||||
<h3 id="continuing-spans-2"><a class="anchor" href="#continuing-spans-2"></a><a class="link" href="#continuing-spans-2">10.3. Continuing Spans</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you want to add tags and annotations to an existing span, you can use the <code>@ContinueSpan</code> annotation, as shown in the following example:</p>
|
||||
</div>
|
||||
@@ -1506,7 +1515,7 @@ this.testBean.testMethod13();</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="advanced-tag-setting"><a class="anchor" href="#advanced-tag-setting"></a><a class="link" href="#advanced-tag-setting">9.4. Advanced Tag Setting</a></h3>
|
||||
<h3 id="advanced-tag-setting"><a class="anchor" href="#advanced-tag-setting"></a><a class="link" href="#advanced-tag-setting">10.4. Advanced Tag Setting</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>There are 3 different ways to add tags to a span. All of them are controlled by the <code>SpanTag</code> annotation.
|
||||
The precedence is as follows:</p>
|
||||
@@ -1528,7 +1537,7 @@ The default implementation uses SPEL expression resolution.
|
||||
</ol>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="custom-extractor"><a class="anchor" href="#custom-extractor"></a><a class="link" href="#custom-extractor">9.4.1. Custom extractor</a></h4>
|
||||
<h4 id="custom-extractor"><a class="anchor" href="#custom-extractor"></a><a class="link" href="#custom-extractor">10.4.1. Custom extractor</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>The value of the tag for the following method is computed by an implementation of <code>TagValueResolver</code> interface.
|
||||
Its class name has to be passed as the value of the <code>resolver</code> attribute.</p>
|
||||
@@ -1560,7 +1569,7 @@ public TagValueResolver tagValueResolver() {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="resolving-expressions-for-a-value"><a class="anchor" href="#resolving-expressions-for-a-value"></a><a class="link" href="#resolving-expressions-for-a-value">9.4.2. Resolving Expressions for a Value</a></h4>
|
||||
<h4 id="resolving-expressions-for-a-value"><a class="anchor" href="#resolving-expressions-for-a-value"></a><a class="link" href="#resolving-expressions-for-a-value">10.4.2. Resolving Expressions for a Value</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Consider the following annotated method:</p>
|
||||
</div>
|
||||
@@ -1578,7 +1587,7 @@ If you want to use some other expression resolution mechanism, you can create yo
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="using-the-tostring-method"><a class="anchor" href="#using-the-tostring-method"></a><a class="link" href="#using-the-tostring-method">9.4.3. Using the <code>toString()</code> method</a></h4>
|
||||
<h4 id="using-the-tostring-method"><a class="anchor" href="#using-the-tostring-method"></a><a class="link" href="#using-the-tostring-method">10.4.3. Using the <code>toString()</code> method</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Consider the following annotated method:</p>
|
||||
</div>
|
||||
@@ -1597,7 +1606,7 @@ public void getAnnotationForArgumentToString(@SpanTag("test") Long param) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="customizations"><a class="anchor" href="#customizations"></a><a class="link" href="#customizations">10. Customizations</a></h2>
|
||||
<h2 id="customizations"><a class="anchor" href="#customizations"></a><a class="link" href="#customizations">11. Customizations</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>The <code>Tracer</code> object is fully managed by sleuth, so you rarely need to affect it. That said,
|
||||
@@ -1631,9 +1640,9 @@ customize behaviour:</p>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="http"><a class="anchor" href="#http"></a><a class="link" href="#http">10.1. HTTP</a></h3>
|
||||
<h3 id="http"><a class="anchor" href="#http"></a><a class="link" href="#http">11.1. HTTP</a></h3>
|
||||
<div class="sect3">
|
||||
<h4 id="data-policy"><a class="anchor" href="#data-policy"></a><a class="link" href="#data-policy">10.1.1. Data Policy</a></h4>
|
||||
<h4 id="data-policy"><a class="anchor" href="#data-policy"></a><a class="link" href="#data-policy">11.1.1. Data Policy</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>The default span data policy for HTTP requests is described in Brave:
|
||||
<a href="https://github.com/openzipkin/brave/tree/master/instrumentation/http#span-data-policy" class="bare">github.com/openzipkin/brave/tree/master/instrumentation/http#span-data-policy</a></p>
|
||||
@@ -1675,7 +1684,7 @@ class Config {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="sampling-2"><a class="anchor" href="#sampling-2"></a><a class="link" href="#sampling-2">10.1.2. Sampling</a></h4>
|
||||
<h4 id="sampling-2"><a class="anchor" href="#sampling-2"></a><a class="link" href="#sampling-2">11.1.2. Sampling</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>If client /server sampling is required, just register a bean of type
|
||||
<code>brave.sampler.SamplerFunction<HttpRequest></code> and name the bean
|
||||
@@ -1718,7 +1727,7 @@ class Config {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="tracingfilter"><a class="anchor" href="#tracingfilter"></a><a class="link" href="#tracingfilter">10.2. <code>TracingFilter</code></a></h3>
|
||||
<h3 id="tracingfilter"><a class="anchor" href="#tracingfilter"></a><a class="link" href="#tracingfilter">11.2. <code>TracingFilter</code></a></h3>
|
||||
<div class="paragraph">
|
||||
<p>You can also modify the behavior of the <code>TracingFilter</code>, which is the component that is responsible for processing the input HTTP request and adding tags basing on the HTTP response.
|
||||
You can customize the tags or modify the response headers by registering your own instance of the <code>TracingFilter</code> bean.</p>
|
||||
@@ -1759,7 +1768,7 @@ class MyFilter extends GenericFilterBean {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="messaging"><a class="anchor" href="#messaging"></a><a class="link" href="#messaging">10.3. Messaging</a></h3>
|
||||
<h3 id="messaging"><a class="anchor" href="#messaging"></a><a class="link" href="#messaging">11.3. Messaging</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Sleuth automatically configures the <code>MessagingTracing</code> bean which serves as a
|
||||
foundation for Messaging instrumentation such as Kafka or JMS.</p>
|
||||
@@ -1792,7 +1801,7 @@ class Config {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="rpc"><a class="anchor" href="#rpc"></a><a class="link" href="#rpc">10.4. RPC</a></h3>
|
||||
<h3 id="rpc"><a class="anchor" href="#rpc"></a><a class="link" href="#rpc">11.4. RPC</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Sleuth automatically configures the <code>RpcTracing</code> bean which serves as a
|
||||
foundation for RPC instrumentation such as gRPC or Dubbo.</p>
|
||||
@@ -1833,7 +1842,7 @@ class Config {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="custom-service-name"><a class="anchor" href="#custom-service-name"></a><a class="link" href="#custom-service-name">10.5. Custom service name</a></h3>
|
||||
<h3 id="custom-service-name"><a class="anchor" href="#custom-service-name"></a><a class="link" href="#custom-service-name">11.5. Custom service name</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>By default, Sleuth assumes that, when you send a span to Zipkin, you want the span’s service name to be equal to the value of the <code>spring.application.name</code> property.
|
||||
That is not always the case, though.
|
||||
@@ -1847,7 +1856,7 @@ To achieve that, you can pass the following property to your application to over
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="customization-of-reported-spans"><a class="anchor" href="#customization-of-reported-spans"></a><a class="link" href="#customization-of-reported-spans">10.6. Customization of Reported Spans</a></h3>
|
||||
<h3 id="customization-of-reported-spans"><a class="anchor" href="#customization-of-reported-spans"></a><a class="link" href="#customization-of-reported-spans">11.6. Customization of Reported Spans</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Before reporting spans (for example, to Zipkin) you may want to modify that span in some way.
|
||||
You can do so by using the <code>FinishedSpanHandler</code> interface.</p>
|
||||
@@ -1890,7 +1899,7 @@ FinishedSpanHandler handlerTwo() {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="host-locator"><a class="anchor" href="#host-locator"></a><a class="link" href="#host-locator">10.7. Host Locator</a></h3>
|
||||
<h3 id="host-locator"><a class="anchor" href="#host-locator"></a><a class="link" href="#host-locator">11.7. Host Locator</a></h3>
|
||||
<div class="admonitionblock important">
|
||||
<table>
|
||||
<tr>
|
||||
@@ -1921,7 +1930,7 @@ If those are not set, we try to retrieve the host name from the network interfac
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="sending-spans-to-zipkin"><a class="anchor" href="#sending-spans-to-zipkin"></a><a class="link" href="#sending-spans-to-zipkin">11. Sending Spans to Zipkin</a></h2>
|
||||
<h2 id="sending-spans-to-zipkin"><a class="anchor" href="#sending-spans-to-zipkin"></a><a class="link" href="#sending-spans-to-zipkin">12. Sending Spans to Zipkin</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>By default, if you add <code>spring-cloud-starter-zipkin</code> as a dependency to your project, when the span is closed, it is sent to Zipkin over HTTP.
|
||||
@@ -2002,7 +2011,7 @@ object, you will have to create a bean of <code>zipkin2.reporter.Sender</code> t
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="zipkin-stream-span-consumer"><a class="anchor" href="#zipkin-stream-span-consumer"></a><a class="link" href="#zipkin-stream-span-consumer">12. Zipkin Stream Span Consumer</a></h2>
|
||||
<h2 id="zipkin-stream-span-consumer"><a class="anchor" href="#zipkin-stream-span-consumer"></a><a class="link" href="#zipkin-stream-span-consumer">13. Zipkin Stream Span Consumer</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="admonitionblock important">
|
||||
<table>
|
||||
@@ -2024,10 +2033,10 @@ In the Finchley release, it got removed.
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="integrations"><a class="anchor" href="#integrations"></a><a class="link" href="#integrations">13. Integrations</a></h2>
|
||||
<h2 id="integrations"><a class="anchor" href="#integrations"></a><a class="link" href="#integrations">14. Integrations</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="sect2">
|
||||
<h3 id="opentracing"><a class="anchor" href="#opentracing"></a><a class="link" href="#opentracing">13.1. OpenTracing</a></h3>
|
||||
<h3 id="opentracing"><a class="anchor" href="#opentracing"></a><a class="link" href="#opentracing">14.1. OpenTracing</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Sleuth is compatible with <a href="https://opentracing.io/">OpenTracing</a>.
|
||||
If you have OpenTracing on the classpath, we automatically register the OpenTracing <code>Tracer</code> bean.
|
||||
@@ -2035,7 +2044,7 @@ If you wish to disable this, set <code>spring.sleuth.opentracing.enabled</code>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="runnable-and-callable"><a class="anchor" href="#runnable-and-callable"></a><a class="link" href="#runnable-and-callable">13.2. Runnable and Callable</a></h3>
|
||||
<h3 id="runnable-and-callable"><a class="anchor" href="#runnable-and-callable"></a><a class="link" href="#runnable-and-callable">14.2. Runnable and Callable</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you wrap your logic in <code>Runnable</code> or <code>Callable</code>, you can wrap those classes in their Sleuth representative, as shown in the following example for <code>Runnable</code>:</p>
|
||||
</div>
|
||||
@@ -2091,13 +2100,13 @@ Callable<String> traceCallableFromTracer = this.tracing.currentTraceContex
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="spring-cloud-circuitbreaker"><a class="anchor" href="#spring-cloud-circuitbreaker"></a><a class="link" href="#spring-cloud-circuitbreaker">13.3. Spring Cloud CircuitBreaker</a></h3>
|
||||
<h3 id="spring-cloud-circuitbreaker"><a class="anchor" href="#spring-cloud-circuitbreaker"></a><a class="link" href="#spring-cloud-circuitbreaker">14.3. Spring Cloud CircuitBreaker</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>If you have Spring Cloud CircuitBreaker on the classpath, we will wrap the passed command <code>Supplier</code> and the fallback <code>Function</code> in its trace representations. In order to disable this instrumentation set <code>spring.sleuth.circuitbreaker.enabled</code> to <code>false</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="rxjava"><a class="anchor" href="#rxjava"></a><a class="link" href="#rxjava">13.4. RxJava</a></h3>
|
||||
<h3 id="rxjava"><a class="anchor" href="#rxjava"></a><a class="link" href="#rxjava">14.4. RxJava</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>We registering a custom <a href="https://github.com/ReactiveX/RxJava/wiki/Plugins#rxjavaschedulershook"><code>RxJavaSchedulersHook</code></a> that wraps all <code>Action0</code> instances in their Sleuth representative, which is called <code>TraceAction</code>.
|
||||
The hook either starts or continues a span, depending on whether tracing was already going on before the Action was scheduled.
|
||||
@@ -2122,12 +2131,12 @@ the Reactor support.
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="http-integration"><a class="anchor" href="#http-integration"></a><a class="link" href="#http-integration">13.5. HTTP integration</a></h3>
|
||||
<h3 id="http-integration"><a class="anchor" href="#http-integration"></a><a class="link" href="#http-integration">14.5. HTTP integration</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Features from this section can be disabled by setting the <code>spring.sleuth.web.enabled</code> property with value equal to <code>false</code>.</p>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="http-filter"><a class="anchor" href="#http-filter"></a><a class="link" href="#http-filter">13.5.1. HTTP Filter</a></h4>
|
||||
<h4 id="http-filter"><a class="anchor" href="#http-filter"></a><a class="link" href="#http-filter">14.5.1. HTTP Filter</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Through the <code>TracingFilter</code>, all sampled incoming requests result in creation of a Span.
|
||||
That Span’s name is <code>http:</code> + the path to which the request was sent.
|
||||
@@ -2151,7 +2160,7 @@ to <code>true</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="handlerinterceptor"><a class="anchor" href="#handlerinterceptor"></a><a class="link" href="#handlerinterceptor">13.5.2. HandlerInterceptor</a></h4>
|
||||
<h4 id="handlerinterceptor"><a class="anchor" href="#handlerinterceptor"></a><a class="link" href="#handlerinterceptor">14.5.2. HandlerInterceptor</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Since we want the span names to be precise, we use a <code>TraceHandlerInterceptor</code> that either wraps an existing <code>HandlerInterceptor</code> or is added directly to the list of existing <code>HandlerInterceptors</code>.
|
||||
The <code>TraceHandlerInterceptor</code> adds a special request attribute to the given <code>HttpServletRequest</code>.
|
||||
@@ -2161,13 +2170,13 @@ In that case, please file an issue in Spring Cloud Sleuth.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="async-servlet-support"><a class="anchor" href="#async-servlet-support"></a><a class="link" href="#async-servlet-support">13.5.3. Async Servlet support</a></h4>
|
||||
<h4 id="async-servlet-support"><a class="anchor" href="#async-servlet-support"></a><a class="link" href="#async-servlet-support">14.5.3. Async Servlet support</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>If your controller returns a <code>Callable</code> or a <code>WebAsyncTask</code>, Spring Cloud Sleuth continues the existing span instead of creating a new one.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="webflux-support"><a class="anchor" href="#webflux-support"></a><a class="link" href="#webflux-support">13.5.4. WebFlux support</a></h4>
|
||||
<h4 id="webflux-support"><a class="anchor" href="#webflux-support"></a><a class="link" href="#webflux-support">14.5.4. WebFlux support</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Through <code>TraceWebFilter</code>, all sampled incoming requests result in creation of a Span.
|
||||
That Span’s name is <code>http:</code> + the path to which the request was sent.
|
||||
@@ -2182,7 +2191,7 @@ If you want to reuse Sleuth’s default skip patterns and append your own, p
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="dubbo-rpc-support"><a class="anchor" href="#dubbo-rpc-support"></a><a class="link" href="#dubbo-rpc-support">13.5.5. Dubbo RPC support</a></h4>
|
||||
<h4 id="dubbo-rpc-support"><a class="anchor" href="#dubbo-rpc-support"></a><a class="link" href="#dubbo-rpc-support">14.5.5. Dubbo RPC support</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Via the integration with Brave, Spring Cloud Sleuth supports <a href="https://dubbo.apache.org/">Dubbo</a>.
|
||||
It’s enough to add the <code>brave-instrumentation-dubbo</code> dependency:</p>
|
||||
@@ -2211,9 +2220,9 @@ An example of Spring Cloud Sleuth and Dubbo can be found <a href="https://github
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="http-client-integration"><a class="anchor" href="#http-client-integration"></a><a class="link" href="#http-client-integration">13.6. HTTP Client Integration</a></h3>
|
||||
<h3 id="http-client-integration"><a class="anchor" href="#http-client-integration"></a><a class="link" href="#http-client-integration">14.6. HTTP Client Integration</a></h3>
|
||||
<div class="sect3">
|
||||
<h4 id="synchronous-rest-template"><a class="anchor" href="#synchronous-rest-template"></a><a class="link" href="#synchronous-rest-template">13.6.1. Synchronous Rest Template</a></h4>
|
||||
<h4 id="synchronous-rest-template"><a class="anchor" href="#synchronous-rest-template"></a><a class="link" href="#synchronous-rest-template">14.6.1. Synchronous Rest Template</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We inject a <code>RestTemplate</code> interceptor to ensure that all the tracing information is passed to the requests.
|
||||
Each time a call is made, a new Span is created.
|
||||
@@ -2235,7 +2244,7 @@ If you create a <code>RestTemplate</code> instance with a <code>new</code> keywo
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="asynchronous-rest-template"><a class="anchor" href="#asynchronous-rest-template"></a><a class="link" href="#asynchronous-rest-template">13.6.2. Asynchronous Rest Template</a></h4>
|
||||
<h4 id="asynchronous-rest-template"><a class="anchor" href="#asynchronous-rest-template"></a><a class="link" href="#asynchronous-rest-template">14.6.2. Asynchronous Rest Template</a></h4>
|
||||
<div class="admonitionblock important">
|
||||
<table>
|
||||
<tr>
|
||||
@@ -2292,7 +2301,7 @@ static class Config {
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="webclient"><a class="anchor" href="#webclient"></a><a class="link" href="#webclient">13.6.3. <code>WebClient</code></a></h4>
|
||||
<h4 id="webclient"><a class="anchor" href="#webclient"></a><a class="link" href="#webclient">14.6.3. <code>WebClient</code></a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We inject a <code>ExchangeFilterFunction</code> implementation that creates a span and, through on-success and on-error callbacks, takes care of closing client-side spans.</p>
|
||||
</div>
|
||||
@@ -2314,7 +2323,7 @@ If you create a <code>WebClient</code> instance with a <code>new</code> keyword,
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="traverson"><a class="anchor" href="#traverson"></a><a class="link" href="#traverson">13.6.4. Traverson</a></h4>
|
||||
<h4 id="traverson"><a class="anchor" href="#traverson"></a><a class="link" href="#traverson">14.6.4. Traverson</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>If you use the <a href="https://docs.spring.io/spring-hateoas/docs/current/reference/html/#client.traverson">Traverson</a> library, you can inject a <code>RestTemplate</code> as a bean into your Traverson object.
|
||||
Since <code>RestTemplate</code> is already intercepted, you get full support for tracing in your client. The following pseudo code
|
||||
@@ -2331,7 +2340,7 @@ Traverson traverson = new Traverson(URI.create("https://some/address"),
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="apache-httpclientbuilder-and-httpasyncclientbuilder"><a class="anchor" href="#apache-httpclientbuilder-and-httpasyncclientbuilder"></a><a class="link" href="#apache-httpclientbuilder-and-httpasyncclientbuilder">13.6.5. Apache <code>HttpClientBuilder</code> and <code>HttpAsyncClientBuilder</code></a></h4>
|
||||
<h4 id="apache-httpclientbuilder-and-httpasyncclientbuilder"><a class="anchor" href="#apache-httpclientbuilder-and-httpasyncclientbuilder"></a><a class="link" href="#apache-httpclientbuilder-and-httpasyncclientbuilder">14.6.5. Apache <code>HttpClientBuilder</code> and <code>HttpAsyncClientBuilder</code></a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument the <code>HttpClientBuilder</code> and <code>HttpAsyncClientBuilder</code> so that
|
||||
tracing context gets injected to the sent requests.</p>
|
||||
@@ -2341,7 +2350,7 @@ tracing context gets injected to the sent requests.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="netty-httpclient"><a class="anchor" href="#netty-httpclient"></a><a class="link" href="#netty-httpclient">13.6.6. Netty <code>HttpClient</code></a></h4>
|
||||
<h4 id="netty-httpclient"><a class="anchor" href="#netty-httpclient"></a><a class="link" href="#netty-httpclient">14.6.6. Netty <code>HttpClient</code></a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument the Netty’s <code>HttpClient</code>.</p>
|
||||
</div>
|
||||
@@ -2363,7 +2372,7 @@ If you create a <code>HttpClient</code> instance with a <code>new</code> keyword
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="userinforesttemplatecustomizer"><a class="anchor" href="#userinforesttemplatecustomizer"></a><a class="link" href="#userinforesttemplatecustomizer">13.6.7. <code>UserInfoRestTemplateCustomizer</code></a></h4>
|
||||
<h4 id="userinforesttemplatecustomizer"><a class="anchor" href="#userinforesttemplatecustomizer"></a><a class="link" href="#userinforesttemplatecustomizer">14.6.7. <code>UserInfoRestTemplateCustomizer</code></a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument the Spring Security’s <code>UserInfoRestTemplateCustomizer</code>.</p>
|
||||
</div>
|
||||
@@ -2373,7 +2382,7 @@ If you create a <code>HttpClient</code> instance with a <code>new</code> keyword
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="feign"><a class="anchor" href="#feign"></a><a class="link" href="#feign">13.7. Feign</a></h3>
|
||||
<h3 id="feign"><a class="anchor" href="#feign"></a><a class="link" href="#feign">14.7. Feign</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>By default, Spring Cloud Sleuth provides integration with Feign through <code>TraceFeignClientAutoConfiguration</code>.
|
||||
You can disable it entirely by setting <code>spring.sleuth.feign.enabled</code> to <code>false</code>.
|
||||
@@ -2387,12 +2396,12 @@ However, all the default instrumentation is still there.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="grpc"><a class="anchor" href="#grpc"></a><a class="link" href="#grpc">13.8. gRPC</a></h3>
|
||||
<h3 id="grpc"><a class="anchor" href="#grpc"></a><a class="link" href="#grpc">14.8. gRPC</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Sleuth provides instrumentation for <a href="https://grpc.io/">gRPC</a> through <code>TraceGrpcAutoConfiguration</code>. You can disable it entirely by setting <code>spring.sleuth.grpc.enabled</code> to <code>false</code>.</p>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="variant-1"><a class="anchor" href="#variant-1"></a><a class="link" href="#variant-1">13.8.1. Variant 1</a></h4>
|
||||
<h4 id="variant-1"><a class="anchor" href="#variant-1"></a><a class="link" href="#variant-1">14.8.1. Variant 1</a></h4>
|
||||
<div class="sect4">
|
||||
<h5 id="dependencies"><a class="anchor" href="#dependencies"></a><a class="link" href="#dependencies">Dependencies</a></h5>
|
||||
<div class="admonitionblock important">
|
||||
@@ -2461,16 +2470,16 @@ Spring Cloud Sleuth provides a <code>SpringAwareManagedChannelBuilder</code> tha
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="variant-2"><a class="anchor" href="#variant-2"></a><a class="link" href="#variant-2">13.8.2. Variant 2</a></h4>
|
||||
<h4 id="variant-2"><a class="anchor" href="#variant-2"></a><a class="link" href="#variant-2">14.8.2. Variant 2</a></h4>
|
||||
<div class="paragraph">
|
||||
<p><a href="https://github.com/yidongnan/grpc-spring-boot-starter">Grpc Spring Boot Starter</a> automatically detects the presence of Spring Cloud Sleuth and brave’s instrumentation for gRPC and registers the necessary client and/or server tooling.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="asynchronous-communication"><a class="anchor" href="#asynchronous-communication"></a><a class="link" href="#asynchronous-communication">13.9. Asynchronous Communication</a></h3>
|
||||
<h3 id="asynchronous-communication"><a class="anchor" href="#asynchronous-communication"></a><a class="link" href="#asynchronous-communication">14.9. Asynchronous Communication</a></h3>
|
||||
<div class="sect3">
|
||||
<h4 id="async-annotated-methods"><a class="anchor" href="#async-annotated-methods"></a><a class="link" href="#async-annotated-methods">13.9.1. <code>@Async</code> Annotated methods</a></h4>
|
||||
<h4 id="async-annotated-methods"><a class="anchor" href="#async-annotated-methods"></a><a class="link" href="#async-annotated-methods">14.9.1. <code>@Async</code> Annotated methods</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>In Spring Cloud Sleuth, we instrument async-related components so that the tracing information is passed between threads.
|
||||
You can disable this behavior by setting the value of <code>spring.sleuth.async.enabled</code> to <code>false</code>.</p>
|
||||
@@ -2493,7 +2502,7 @@ You can disable this behavior by setting the value of <code>spring.sleuth.async.
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="scheduled-annotated-methods"><a class="anchor" href="#scheduled-annotated-methods"></a><a class="link" href="#scheduled-annotated-methods">13.9.2. <code>@Scheduled</code> Annotated Methods</a></h4>
|
||||
<h4 id="scheduled-annotated-methods"><a class="anchor" href="#scheduled-annotated-methods"></a><a class="link" href="#scheduled-annotated-methods">14.9.2. <code>@Scheduled</code> Annotated Methods</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>In Spring Cloud Sleuth, we instrument scheduled method execution so that the tracing information is passed between threads.
|
||||
You can disable this behavior by setting the value of <code>spring.sleuth.scheduled.enabled</code> to <code>false</code>.</p>
|
||||
@@ -2516,7 +2525,7 @@ You can disable this behavior by setting the value of <code>spring.sleuth.schedu
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="executor-executorservice-and-scheduledexecutorservice"><a class="anchor" href="#executor-executorservice-and-scheduledexecutorservice"></a><a class="link" href="#executor-executorservice-and-scheduledexecutorservice">13.9.3. Executor, ExecutorService, and ScheduledExecutorService</a></h4>
|
||||
<h4 id="executor-executorservice-and-scheduledexecutorservice"><a class="anchor" href="#executor-executorservice-and-scheduledexecutorservice"></a><a class="link" href="#executor-executorservice-and-scheduledexecutorservice">14.9.3. Executor, ExecutorService, and ScheduledExecutorService</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We provide <code>LazyTraceExecutor</code>, <code>TraceableExecutorService</code>, and <code>TraceableScheduledExecutorService</code>. Those implementations create spans each time a new task is submitted, invoked, or scheduled.</p>
|
||||
</div>
|
||||
@@ -2603,12 +2612,12 @@ to add the <code>@Role(BeanDefinition.ROLE_INFRASTRUCTURE)</code> on your
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="messaging-2"><a class="anchor" href="#messaging-2"></a><a class="link" href="#messaging-2">13.10. Messaging</a></h3>
|
||||
<h3 id="messaging-2"><a class="anchor" href="#messaging-2"></a><a class="link" href="#messaging-2">14.10. Messaging</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>Features from this section can be disabled by setting the <code>spring.sleuth.messaging.enabled</code> property with value equal to <code>false</code>.</p>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="spring-integration-and-spring-cloud-stream"><a class="anchor" href="#spring-integration-and-spring-cloud-stream"></a><a class="link" href="#spring-integration-and-spring-cloud-stream">13.10.1. Spring Integration and Spring Cloud Stream</a></h4>
|
||||
<h4 id="spring-integration-and-spring-cloud-stream"><a class="anchor" href="#spring-integration-and-spring-cloud-stream"></a><a class="link" href="#spring-integration-and-spring-cloud-stream">14.10.1. Spring Integration and Spring Cloud Stream</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>Spring Cloud Sleuth integrates with <a href="https://projects.spring.io/spring-integration/">Spring Integration</a>.
|
||||
It creates spans for publish and subscribe events.
|
||||
@@ -2647,7 +2656,7 @@ it’s enough for you to register beans of types:</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="spring-rabbitmq"><a class="anchor" href="#spring-rabbitmq"></a><a class="link" href="#spring-rabbitmq">13.10.2. Spring RabbitMq</a></h4>
|
||||
<h4 id="spring-rabbitmq"><a class="anchor" href="#spring-rabbitmq"></a><a class="link" href="#spring-rabbitmq">14.10.2. Spring RabbitMq</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument the <code>RabbitTemplate</code> so that tracing headers get injected
|
||||
into the message.</p>
|
||||
@@ -2657,7 +2666,7 @@ into the message.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="spring-kafka"><a class="anchor" href="#spring-kafka"></a><a class="link" href="#spring-kafka">13.10.3. Spring Kafka</a></h4>
|
||||
<h4 id="spring-kafka"><a class="anchor" href="#spring-kafka"></a><a class="link" href="#spring-kafka">14.10.3. Spring Kafka</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument the Spring Kafka’s <code>ProducerFactory</code> and <code>ConsumerFactory</code>
|
||||
so that tracing headers get injected into the created Spring Kafka’s
|
||||
@@ -2668,7 +2677,7 @@ so that tracing headers get injected into the created Spring Kafka’s
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="spring-kafka-streams"><a class="anchor" href="#spring-kafka-streams"></a><a class="link" href="#spring-kafka-streams">13.10.4. Spring Kafka Streams</a></h4>
|
||||
<h4 id="spring-kafka-streams"><a class="anchor" href="#spring-kafka-streams"></a><a class="link" href="#spring-kafka-streams">14.10.4. Spring Kafka Streams</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument the <code>KafkaStreams</code> <code>KafkaClientSupplier</code> so that tracing headers
|
||||
get injected into the <code>Producer</code> and <code>Consumer`s. A `KafkaStreamsTracing</code> bean
|
||||
@@ -2680,7 +2689,7 @@ allows for further instrumentation through additional <code>TransformerSupplier<
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="spring-jms"><a class="anchor" href="#spring-jms"></a><a class="link" href="#spring-jms">13.10.5. Spring JMS</a></h4>
|
||||
<h4 id="spring-jms"><a class="anchor" href="#spring-jms"></a><a class="link" href="#spring-jms">14.10.5. Spring JMS</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument the <code>JmsTemplate</code> so that tracing headers get injected
|
||||
into the message. We also support <code>@JmsListener</code> annotated methods on the consumer side.</p>
|
||||
@@ -2702,7 +2711,7 @@ We don’t support baggage propagation for JMS
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect3">
|
||||
<h4 id="spring-cloud-aws-messaging-sqs"><a class="anchor" href="#spring-cloud-aws-messaging-sqs"></a><a class="link" href="#spring-cloud-aws-messaging-sqs">13.10.6. Spring Cloud AWS Messaging SQS</a></h4>
|
||||
<h4 id="spring-cloud-aws-messaging-sqs"><a class="anchor" href="#spring-cloud-aws-messaging-sqs"></a><a class="link" href="#spring-cloud-aws-messaging-sqs">14.10.6. Spring Cloud AWS Messaging SQS</a></h4>
|
||||
<div class="paragraph">
|
||||
<p>We instrument <code>@SqsListener</code> which is provided by <code>org.springframework.cloud:spring-cloud-aws-messaging</code>
|
||||
so that tracing headers get extracted from the message and a trace gets put into the context.</p>
|
||||
@@ -2713,14 +2722,14 @@ so that tracing headers get extracted from the message and a trace gets put into
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="redis"><a class="anchor" href="#redis"></a><a class="link" href="#redis">13.11. Redis</a></h3>
|
||||
<h3 id="redis"><a class="anchor" href="#redis"></a><a class="link" href="#redis">14.11. Redis</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>We set <code>tracing</code> property to Lettcue <code>ClientResources</code> instance to enable Brave tracing built in Lettuce .
|
||||
To disable Redis support, set the <code>spring.sleuth.redis.enabled</code> property to <code>false</code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="quartz"><a class="anchor" href="#quartz"></a><a class="link" href="#quartz">13.12. Quartz</a></h3>
|
||||
<h3 id="quartz"><a class="anchor" href="#quartz"></a><a class="link" href="#quartz">14.12. Quartz</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>We instrument quartz jobs by adding Job/Trigger listeners to the Quartz Scheduler.</p>
|
||||
</div>
|
||||
@@ -2729,7 +2738,7 @@ To disable Redis support, set the <code>spring.sleuth.redis.enabled</code> prope
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="project-reactor"><a class="anchor" href="#project-reactor"></a><a class="link" href="#project-reactor">13.13. Project Reactor</a></h3>
|
||||
<h3 id="project-reactor"><a class="anchor" href="#project-reactor"></a><a class="link" href="#project-reactor">14.13. Project Reactor</a></h3>
|
||||
<div class="paragraph">
|
||||
<p>For projects depending on Project Reactor such as Spring Cloud Gateway, we suggest turning the <code>spring.sleuth.reactor.decorate-on-each</code> option to <code>false</code>. That way an increased performance gain should be observed in comparison to the standard instrumentation mechanism. What this option does is it will wrap decorate <code>onLast</code> operator instead of <code>onEach</code> which will result in creation of far fewer objects. The downside of this is that when Project Reactor will change threads, the trace propagation will continue without issues, however anything relying on the <code>ThreadLocal</code> such as e.g. MDC entries can be buggy.</p>
|
||||
</div>
|
||||
@@ -2737,7 +2746,7 @@ To disable Redis support, set the <code>spring.sleuth.redis.enabled</code> prope
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="configuration-properties"><a class="anchor" href="#configuration-properties"></a><a class="link" href="#configuration-properties">14. Configuration properties</a></h2>
|
||||
<h2 id="configuration-properties"><a class="anchor" href="#configuration-properties"></a><a class="link" href="#configuration-properties">15. Configuration properties</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>To see the list of all Sleuth related configuration properties please check <a href="appendix.html">the Appendix page</a>.</p>
|
||||
@@ -2745,7 +2754,7 @@ To disable Redis support, set the <code>spring.sleuth.redis.enabled</code> prope
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="running-examples"><a class="anchor" href="#running-examples"></a><a class="link" href="#running-examples">15. Running examples</a></h2>
|
||||
<h2 id="running-examples"><a class="anchor" href="#running-examples"></a><a class="link" href="#running-examples">16. Running examples</a></h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>You can see the running examples deployed in the <a href="https://run.pivotal.io/">Pivotal Web Services</a>.
|
||||
|
||||
Reference in New Issue
Block a user