diff --git a/reference/html/index.html b/reference/html/index.html index 73605f120..8820fde0c 100644 --- a/reference/html/index.html +++ b/reference/html/index.html @@ -159,9 +159,10 @@ $(addBlockSwitches);
  • 12.1. Customizers
  • 12.2. HTTP
  • 12.3. TracingFilter
  • -
  • 12.4. Custom service name
  • -
  • 12.5. Customization of Reported Spans
  • -
  • 12.6. Host Locator
  • +
  • 12.4. RPC
  • +
  • 12.5. Custom service name
  • +
  • 12.6. Customization of Reported Spans
  • +
  • 12.7. Host Locator
  • 13. Sending Spans to Zipkin
  • @@ -2515,14 +2516,17 @@ public void getAnnotationForArgumentToString(@SpanTag("test") Long param) {

    12.2. HTTP

    -

    If a customization of client / server parsing of the HTTP related spans is required, -just register a bean of type brave.http.HttpClientParser or +

    If a customization of client / server parsing of the HTTP related spans is +required, just register a bean of type brave.http.HttpClientParser or brave.http.HttpServerParser. If client /server sampling is required, just -register a bean of type brave.http.HttpSampler and name the bean - sleuthClientSampler for client sampler and sleuthServerSampler for server sampler. - For your convenience the @ClientSampler and @ServerSampler - annotations can be used to inject the proper beans or to - reference the bean names via their static String NAME fields.

    +register a bean of type brave.sampler.SamplerFunction<HttpRequest> and name +the bean sleuthHttpClientSampler for client sampler and +sleuthHttpServerSampler for server sampler.

    +
    +
    +

    For your convenience the @HttpClientSampler and @HttpServerSampler +annotations can be used to inject the proper beans or to reference the bean +names via their static String NAME fields.

    Check out Brave’s code to see an example of how to make a path-based sampler @@ -2531,26 +2535,22 @@ register a bean of type brave.http.HttpSampler and name the bean

    If you want to completely rewrite the HttpTracing bean you can use the SkipPatternProvider interface to retrieve the URL Pattern for spans that should be not sampled. Below you can see -an example of usage of SkipPatternProvider inside a server side, HttpSampler.

    +an example of usage of SkipPatternProvider inside a server side, Sampler<HttpRequest>.

    @Configuration
     class Config {
    -  @Bean(name = ServerSampler.NAME)
    -  HttpSampler myHttpSampler(SkipPatternProvider provider) {
    +  @Bean(name = HttpServerSampler.NAME)
    +  SamplerFunction<HttpRequest> myHttpSampler(SkipPatternProvider provider) {
           Pattern pattern = provider.skipPattern();
    -      return new HttpSampler() {
    -
    -          @Override
    -          public <Req> Boolean trySample(HttpAdapter<Req, ?> adapter, Req request) {
    -              String url = adapter.path(request);
    -              boolean shouldSkip = pattern.matcher(url).matches();
    -              if (shouldSkip) {
    -                  return false;
    -              }
    -              return null;
    +      return request -> {
    +          String url = request.path();
    +          boolean shouldSkip = pattern.matcher(url).matches();
    +          if (shouldSkip) {
    +              return false;
               }
    +          return null;
           };
       }
     }
    @@ -2599,7 +2599,48 @@ class MyFilter extends GenericFilterBean {
    -

    12.4. Custom service name

    +

    12.4. RPC

    +
    +

    Sleuth automatically configures the RpcTracing bean which serves as a +foundation for RPC instrumentation such as gRPC or Dubbo.

    +
    +
    +

    If a customization of client / server sampling of the RPC traces is required, +just register a bean of type brave.sampler.SamplerFunction<RpcRequest> and +name the bean sleuthRpcClientSampler for client sampler and +sleuthRpcServerSampler for server sampler.

    +
    +
    +

    For your convenience the @RpcClientSampler and @RpcServerSampler +annotations can be used to inject the proper beans or to reference the bean +names via their static String NAME fields.

    +
    +
    +

    Ex. Here’s a sampler that traces 100 "GetUserToken" server requests per second. +This doesn’t start new traces for requests to the health check service. Other +requests will use the global sampling configuration.

    +
    +
    +
    +
    @Configuration
    +class Config {
    +  @Bean(name = RpcServerSampler.NAME)
    +  SamplerFunction<RpcRequest> myRpcSampler() {
    +      Matcher<RpcRequest> 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();
    +  }
    +}
    +
    +
    + +
    +
    +

    12.5. Custom service name

    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 spring.application.name 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

    -

    12.5. Customization of Reported Spans

    +

    12.6. Customization of Reported Spans

    Before reporting spans (for example, to Zipkin) you may want to modify that span in some way. You can do so by using the FinishedSpanHandler interface.

    @@ -2656,7 +2697,7 @@ FinishedSpanHandler handlerTwo() {
    -

    12.6. Host Locator

    +

    12.7. Host Locator

    @@ -2987,13 +3028,13 @@ If you want to reuse Sleuth’s default skip patterns and append your own, p

    15.5.5. Dubbo RPC support

    Via the integration with Brave, Spring Cloud Sleuth supports Dubbo. -It’s enough to add the brave-instrumentation-dubbo-rpc dependency:

    +It’s enough to add the brave-instrumentation-dubbo dependency:

    <dependency>
         <groupId>io.zipkin.brave</groupId>
    -    <artifactId>brave-instrumentation-dubbo-rpc</artifactId>
    +    <artifactId>brave-instrumentation-dubbo</artifactId>
     </dependency>
    diff --git a/reference/html/spring-cloud-sleuth.html b/reference/html/spring-cloud-sleuth.html index 73605f120..8820fde0c 100644 --- a/reference/html/spring-cloud-sleuth.html +++ b/reference/html/spring-cloud-sleuth.html @@ -159,9 +159,10 @@ $(addBlockSwitches);
  • 12.1. Customizers
  • 12.2. HTTP
  • 12.3. TracingFilter
  • -
  • 12.4. Custom service name
  • -
  • 12.5. Customization of Reported Spans
  • -
  • 12.6. Host Locator
  • +
  • 12.4. RPC
  • +
  • 12.5. Custom service name
  • +
  • 12.6. Customization of Reported Spans
  • +
  • 12.7. Host Locator
  • 13. Sending Spans to Zipkin
  • @@ -2515,14 +2516,17 @@ public void getAnnotationForArgumentToString(@SpanTag("test") Long param) {

    12.2. HTTP

    -

    If a customization of client / server parsing of the HTTP related spans is required, -just register a bean of type brave.http.HttpClientParser or +

    If a customization of client / server parsing of the HTTP related spans is +required, just register a bean of type brave.http.HttpClientParser or brave.http.HttpServerParser. If client /server sampling is required, just -register a bean of type brave.http.HttpSampler and name the bean - sleuthClientSampler for client sampler and sleuthServerSampler for server sampler. - For your convenience the @ClientSampler and @ServerSampler - annotations can be used to inject the proper beans or to - reference the bean names via their static String NAME fields.

    +register a bean of type brave.sampler.SamplerFunction<HttpRequest> and name +the bean sleuthHttpClientSampler for client sampler and +sleuthHttpServerSampler for server sampler.

    +
    +
    +

    For your convenience the @HttpClientSampler and @HttpServerSampler +annotations can be used to inject the proper beans or to reference the bean +names via their static String NAME fields.

    Check out Brave’s code to see an example of how to make a path-based sampler @@ -2531,26 +2535,22 @@ register a bean of type brave.http.HttpSampler and name the bean

    If you want to completely rewrite the HttpTracing bean you can use the SkipPatternProvider interface to retrieve the URL Pattern for spans that should be not sampled. Below you can see -an example of usage of SkipPatternProvider inside a server side, HttpSampler.

    +an example of usage of SkipPatternProvider inside a server side, Sampler<HttpRequest>.

    @Configuration
     class Config {
    -  @Bean(name = ServerSampler.NAME)
    -  HttpSampler myHttpSampler(SkipPatternProvider provider) {
    +  @Bean(name = HttpServerSampler.NAME)
    +  SamplerFunction<HttpRequest> myHttpSampler(SkipPatternProvider provider) {
           Pattern pattern = provider.skipPattern();
    -      return new HttpSampler() {
    -
    -          @Override
    -          public <Req> Boolean trySample(HttpAdapter<Req, ?> adapter, Req request) {
    -              String url = adapter.path(request);
    -              boolean shouldSkip = pattern.matcher(url).matches();
    -              if (shouldSkip) {
    -                  return false;
    -              }
    -              return null;
    +      return request -> {
    +          String url = request.path();
    +          boolean shouldSkip = pattern.matcher(url).matches();
    +          if (shouldSkip) {
    +              return false;
               }
    +          return null;
           };
       }
     }
    @@ -2599,7 +2599,48 @@ class MyFilter extends GenericFilterBean {
    -

    12.4. Custom service name

    +

    12.4. RPC

    +
    +

    Sleuth automatically configures the RpcTracing bean which serves as a +foundation for RPC instrumentation such as gRPC or Dubbo.

    +
    +
    +

    If a customization of client / server sampling of the RPC traces is required, +just register a bean of type brave.sampler.SamplerFunction<RpcRequest> and +name the bean sleuthRpcClientSampler for client sampler and +sleuthRpcServerSampler for server sampler.

    +
    +
    +

    For your convenience the @RpcClientSampler and @RpcServerSampler +annotations can be used to inject the proper beans or to reference the bean +names via their static String NAME fields.

    +
    +
    +

    Ex. Here’s a sampler that traces 100 "GetUserToken" server requests per second. +This doesn’t start new traces for requests to the health check service. Other +requests will use the global sampling configuration.

    +
    +
    +
    +
    @Configuration
    +class Config {
    +  @Bean(name = RpcServerSampler.NAME)
    +  SamplerFunction<RpcRequest> myRpcSampler() {
    +      Matcher<RpcRequest> 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();
    +  }
    +}
    +
    +
    + +
    +
    +

    12.5. Custom service name

    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 spring.application.name 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

    -

    12.5. Customization of Reported Spans

    +

    12.6. Customization of Reported Spans

    Before reporting spans (for example, to Zipkin) you may want to modify that span in some way. You can do so by using the FinishedSpanHandler interface.

    @@ -2656,7 +2697,7 @@ FinishedSpanHandler handlerTwo() {
    @@ -2987,13 +3028,13 @@ If you want to reuse Sleuth’s default skip patterns and append your own, p

    15.5.5. Dubbo RPC support

    Via the integration with Brave, Spring Cloud Sleuth supports Dubbo. -It’s enough to add the brave-instrumentation-dubbo-rpc dependency:

    +It’s enough to add the brave-instrumentation-dubbo dependency:

    <dependency>
         <groupId>io.zipkin.brave</groupId>
    -    <artifactId>brave-instrumentation-dubbo-rpc</artifactId>
    +    <artifactId>brave-instrumentation-dubbo</artifactId>
     </dependency>