Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2019-10-03 10:27:43 +00:00
parent cb57c6e9df
commit f7ed30731b
2 changed files with 138 additions and 56 deletions

View File

@@ -159,9 +159,10 @@ $(addBlockSwitches);
<li><a href="#customizers">12.1. Customizers</a></li>
<li><a href="#http">12.2. HTTP</a></li>
<li><a href="#tracingfilter">12.3. <code>TracingFilter</code></a></li>
<li><a href="#custom-service-name">12.4. Custom service name</a></li>
<li><a href="#customization-of-reported-spans">12.5. Customization of Reported Spans</a></li>
<li><a href="#host-locator">12.6. Host Locator</a></li>
<li><a href="#rpc">12.4. RPC</a></li>
<li><a href="#custom-service-name">12.5. Custom service name</a></li>
<li><a href="#customization-of-reported-spans">12.6. Customization of Reported Spans</a></li>
<li><a href="#host-locator">12.7. Host Locator</a></li>
</ul>
</li>
<li><a href="#sending-spans-to-zipkin">13. Sending Spans to Zipkin</a></li>
@@ -2515,14 +2516,17 @@ public void getAnnotationForArgumentToString(@SpanTag("test") Long param) {
<div class="sect2">
<h3 id="http"><a class="anchor" href="#http"></a><a class="link" href="#http">12.2. HTTP</a></h3>
<div class="paragraph">
<p>If a customization of client / server parsing of the HTTP related spans is required,
just register a bean of type <code>brave.http.HttpClientParser</code> or
<p>If a customization of client / server parsing of the HTTP related spans is
required, just register a bean of type <code>brave.http.HttpClientParser</code> or
<code>brave.http.HttpServerParser</code>. If client /server sampling is required, just
register a bean of type <code>brave.http.HttpSampler</code> and name the bean
<code>sleuthClientSampler</code> for client sampler and <code>sleuthServerSampler</code> for server sampler.
For your convenience the <code>@ClientSampler</code> and <code>@ServerSampler</code>
annotations can be used to inject the proper beans or to
reference the bean names via their static String <code>NAME</code> fields.</p>
register a bean of type <code>brave.sampler.SamplerFunction&lt;HttpRequest&gt;</code> and name
the bean <code>sleuthHttpClientSampler</code> for client sampler and
<code>sleuthHttpServerSampler</code> for server sampler.</p>
</div>
<div class="paragraph">
<p>For your convenience the <code>@HttpClientSampler</code> and <code>@HttpServerSampler</code>
annotations can be used to inject the proper beans or to reference the bean
names via their static String <code>NAME</code> fields.</p>
</div>
<div class="paragraph">
<p>Check out Brave&#8217;s code to see an example of how to make a path-based sampler
@@ -2531,26 +2535,22 @@ register a bean of type <code>brave.http.HttpSampler</code> and name the bean
<div class="paragraph">
<p>If you want to completely rewrite the <code>HttpTracing</code> bean you can use the <code>SkipPatternProvider</code>
interface to retrieve the URL <code>Pattern</code> for spans that should be not sampled. Below you can see
an example of usage of <code>SkipPatternProvider</code> inside a server side, <code>HttpSampler</code>.</p>
an example of usage of <code>SkipPatternProvider</code> inside a server side, <code>Sampler&lt;HttpRequest&gt;</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@Configuration
class Config {
@Bean(name = ServerSampler.NAME)
HttpSampler myHttpSampler(SkipPatternProvider provider) {
@Bean(name = HttpServerSampler.NAME)
SamplerFunction&lt;HttpRequest&gt; myHttpSampler(SkipPatternProvider provider) {
Pattern pattern = provider.skipPattern();
return new HttpSampler() {
@Override
public &lt;Req&gt; Boolean trySample(HttpAdapter&lt;Req, ?&gt; adapter, Req request) {
String url = adapter.path(request);
boolean shouldSkip = pattern.matcher(url).matches();
if (shouldSkip) {
return false;
}
return null;
return request -&gt; {
String url = request.path();
boolean shouldSkip = pattern.matcher(url).matches();
if (shouldSkip) {
return false;
}
return null;
};
}
}</code></pre>
@@ -2599,7 +2599,48 @@ class MyFilter extends GenericFilterBean {
</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">12.4. Custom service name</a></h3>
<h3 id="rpc"><a class="anchor" href="#rpc"></a><a class="link" href="#rpc">12.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>
</div>
<div class="paragraph">
<p>If a customization of client / server sampling of the RPC traces is required,
just register a bean of type <code>brave.sampler.SamplerFunction&lt;RpcRequest&gt;</code> and
name the bean <code>sleuthRpcClientSampler</code> for client sampler and
<code>sleuthRpcServerSampler</code> for server sampler.</p>
</div>
<div class="paragraph">
<p>For your convenience the <code>@RpcClientSampler</code> and <code>@RpcServerSampler</code>
annotations can be used to inject the proper beans or to reference the bean
names via their static String <code>NAME</code> fields.</p>
</div>
<div class="paragraph">
<p>Ex. Here&#8217;s a sampler that traces 100 "GetUserToken" server requests per second.
This doesn&#8217;t start new traces for requests to the health check service. Other
requests will use the global sampling configuration.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@Configuration
class Config {
@Bean(name = RpcServerSampler.NAME)
SamplerFunction&lt;RpcRequest&gt; myRpcSampler() {
Matcher&lt;RpcRequest&gt; userAuth = and(serviceEquals("users.UserService"),
methodEquals("GetUserToken"));
return RpcRuleSampler.newBuilder()
.putRule(serviceEquals("grpc.health.v1.Health"), Sampler.NEVER_SAMPLE)
.putRule(userAuth, RateLimitingSampler.create(100)).build();
}
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>For more, see <a href="https://github.com/openzipkin/brave/tree/master/instrumentation/rpc#sampling-policy" class="bare">github.com/openzipkin/brave/tree/master/instrumentation/rpc#sampling-policy</a></p>
</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">12.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&#8217;s service name to be equal to the value of the <code>spring.application.name</code> property.
That is not always the case, though.
@@ -2613,7 +2654,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">12.5. 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">12.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>
@@ -2656,7 +2697,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">12.6. Host Locator</a></h3>
<h3 id="host-locator"><a class="anchor" href="#host-locator"></a><a class="link" href="#host-locator">12.7. Host Locator</a></h3>
<div class="admonitionblock important">
<table>
<tr>
@@ -2987,13 +3028,13 @@ If you want to reuse Sleuth&#8217;s default skip patterns and append your own, p
<h4 id="dubbo-rpc-support"><a class="anchor" href="#dubbo-rpc-support"></a><a class="link" href="#dubbo-rpc-support">15.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&#8217;s enough to add the <code>brave-instrumentation-dubbo-rpc</code> dependency:</p>
It&#8217;s enough to add the <code>brave-instrumentation-dubbo</code> dependency:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml">&lt;dependency&gt;
&lt;groupId&gt;io.zipkin.brave&lt;/groupId&gt;
&lt;artifactId&gt;brave-instrumentation-dubbo-rpc&lt;/artifactId&gt;
&lt;artifactId&gt;brave-instrumentation-dubbo&lt;/artifactId&gt;
&lt;/dependency&gt;</code></pre>
</div>
</div>