From edd8754a6ae510273fb37164ffd32334466217aa Mon Sep 17 00:00:00 2001 From: buildmaster Date: Mon, 20 Nov 2017 22:07:53 +0000 Subject: [PATCH] Sync docs from master to gh-pages --- multi/multi__customizations.html | 15 +------------ multi/multi__features.html | 2 +- multi/multi__introduction.html | 20 ++++++++--------- single/spring-cloud-sleuth.html | 37 +++++++++++--------------------- spring-cloud-sleuth.xml | 37 +++++++++++--------------------- 5 files changed, 36 insertions(+), 75 deletions(-) diff --git a/multi/multi__customizations.html b/multi/multi__customizations.html index bf015a354..41e61c5ba 100644 --- a/multi/multi__customizations.html +++ b/multi/multi__customizations.html @@ -119,20 +119,7 @@ TraceFilter myTraceFilter(BeanFactory beanFactory,

9.5 Custom SA tag in Zipkin

Sometimes you want to create a manual Span that will wrap a call to an external service which is not instrumented. What you can do is to create a span with the peer.service tag that will contain a value of the service that you want to call. -Below you can see an example of a call to Redis that is wrapped in such a span.

org.springframework.cloud.sleuth.Span newSpan = tracer.createSpan("redis");
-try {
-	newSpan.tag("redis.op", "get");
-	newSpan.tag("lc", "redis");
-	newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_SEND);
-	// call redis service e.g
-	// return (SomeObj) redisTemplate.opsForHash().get("MYHASH", someObjKey);
-} finally {
-	newSpan.tag("peer.service", "redisService");
-	newSpan.tag("peer.ipv4", "1.2.3.4");
-	newSpan.tag("peer.port", "1234");
-	newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_RECV);
-	tracer.close(newSpan);
-}
[Important]Important

Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

9.6 Custom service name

By default Sleuth assumes that when you send a span to Zipkin, you want the span’s service name +Below you can see an example of a call to Redis that is wrapped in such a span.

Unresolved directive in spring-cloud-sleuth.adoc - include::../../../..//spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java[tags=service_name,indent=0]
[Important]Important

Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

9.6 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 spring.application.name value. That’s not always the case though. There are situations in which you want to explicitly provide a different service name for all spans coming from your application. To achieve that it’s enough to just pass the following property diff --git a/multi/multi__features.html b/multi/multi__features.html index d3502ab6d..bb705d5d4 100644 --- a/multi/multi__features.html +++ b/multi/multi__features.html @@ -10,7 +10,7 @@ latency in your applications. Sleuth is written to not log too much, and to not rest template, scheduled actions, message channels, zuul filters, feign client).

  • Sleuth includes default logic to join a trace across http or messaging boundaries. For example, http propagation works via Zipkin-compatible request headers. This propagation logic is defined and customized via SpanInjector and SpanExtractor implementations.
  • Sleuth gives you the possibility to propagate context (also known as baggage) between processes. That means that if you set on a Span -a baggage element then it will be sent downstream either via HTTP or messaging to other processes.
  • Provides a way to create / continue spans and add tags and logs via annotations.
  • Provides simple metrics of accepted / dropped spans.
  • If spring-cloud-sleuth-zipkin2 then the app will generate and collect Zipkin-compatible traces. +a baggage element then it will be sent downstream either via HTTP or messaging to other processes.

  • Provides a way to create / continue spans and add tags and logs via annotations.
  • Provides simple metrics of accepted / dropped spans.
  • If spring-cloud-sleuth-zipkin then the app will generate and collect Zipkin-compatible traces. By default it sends them via HTTP to a Zipkin server on localhost (port 9411). Configure the location of the service using spring.zipkin.baseUrl.

    • If you depend on spring-rabbit or spring-kafka your app will send traces to a broker instead of http.
    • Note: spring-cloud-sleuth-stream is deprecated and should no longer be used.
  • [Important]Important

    If using Zipkin, configure the percentage of spans exported using spring.sleuth.sampler.percentage (default 0.1, i.e. 10%). Otherwise you might think that Sleuth is not working cause it’s omitting some spans.

    [Note]Note

    the SLF4J MDC is always set and logback users will immediately see the trace and span ids in logs per the example diff --git a/multi/multi__introduction.html b/multi/multi__introduction.html index cb0ae00e0..0e1416cb8 100644 --- a/multi/multi__introduction.html +++ b/multi/multi__introduction.html @@ -169,7 +169,7 @@ dependencies { "org.springframework.cloud:spring-cloud-starter-sleuth" }

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-sleuth

    1.3.2 Sleuth with Zipkin via HTTP

    If you want both Sleuth and Zipkin just add the spring-cloud-starter-zipkin2 dependency.

    Maven.  +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-sleuth

    1.3.2 Sleuth with Zipkin via HTTP

    If you want both Sleuth and Zipkin just add the spring-cloud-starter-zipkin dependency.

    Maven. 

    <dependencyManagement> 1
              <dependencies>
                  <dependency>
    @@ -184,10 +184,10 @@ the Spring BOM

    <dependency> 2 <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starter-zipkin2</artifactId> + <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency>

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2

    Gradle.  +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin

    Gradle. 

    dependencyManagement { 1
         imports {
             mavenBom "org.springframework.cloud:spring-cloud-dependencies:${releaseTrainVersion}"
    @@ -195,11 +195,11 @@ the Spring BOM

    2 - compile "org.springframework.cloud:spring-cloud-starter-zipkin2" + compile "org.springframework.cloud:spring-cloud-starter-zipkin" }

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2

    1.3.3 Sleuth with Zipkin via RabbitMQ or Kafka

    If you want to use RabbitMQ or Kafka instead of http, add the spring-rabbit or spring-kafka -dependencies. The default destination name is zipkin.

    Note: spring-cloud-sleuth-stream is deprecated and incompatible with these destinations

    If you want Sleuth over RabbitMQ add the spring-cloud-starter-zipkin2 and spring-rabbit +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin

    1.3.3 Sleuth with Zipkin via RabbitMQ or Kafka

    If you want to use RabbitMQ or Kafka instead of http, add the spring-rabbit or spring-kafka +dependencies. The default destination name is zipkin.

    Note: spring-cloud-sleuth-stream is deprecated and incompatible with these destinations

    If you want Sleuth over RabbitMQ add the spring-cloud-starter-zipkin and spring-rabbit dependencies.

    Maven. 

    <dependencyManagement> 1
              <dependencies>
    @@ -215,14 +215,14 @@ dependencies.

    Maven.  <dependency> 2 <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starter-zipkin2</artifactId> + <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> <dependency> 3 <groupId>org.springframework.amqp</groupId> <artifactId>spring-rabbit</artifactId> </dependency>

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2 - that way all dependent dependencies will be downloaded

    3

    To automatically configure rabbit, simply add the spring-rabbit dependency

    Gradle.  +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded

    3

    To automatically configure rabbit, simply add the spring-rabbit dependency

    Gradle. 

    dependencyManagement { 1
         imports {
             mavenBom "org.springframework.cloud:spring-cloud-dependencies:${releaseTrainVersion}"
    @@ -230,8 +230,8 @@ the Spring BOM

    "org.springframework.cloud:spring-cloud-starter-zipkin2" 2 + compile "org.springframework.cloud:spring-cloud-starter-zipkin" 2 compile "org.springframework.amqp:spring-rabbit" 3 }

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2 - that way all dependent dependencies will be downloaded

    3

    To automatically configure rabbit, simply add the spring-rabbit dependency

    \ No newline at end of file +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded

    3

    To automatically configure rabbit, simply add the spring-rabbit dependency

    \ No newline at end of file diff --git a/single/spring-cloud-sleuth.html b/single/spring-cloud-sleuth.html index f08ced0da..4ade3e8ca 100644 --- a/single/spring-cloud-sleuth.html +++ b/single/spring-cloud-sleuth.html @@ -169,7 +169,7 @@ dependencies { "org.springframework.cloud:spring-cloud-starter-sleuth" }

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-sleuth

    1.3.2 Sleuth with Zipkin via HTTP

    If you want both Sleuth and Zipkin just add the spring-cloud-starter-zipkin2 dependency.

    Maven.  +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-sleuth

    1.3.2 Sleuth with Zipkin via HTTP

    If you want both Sleuth and Zipkin just add the spring-cloud-starter-zipkin dependency.

    Maven. 

    <dependencyManagement> 1
              <dependencies>
                  <dependency>
    @@ -184,10 +184,10 @@ the Spring BOM

    <dependency> 2 <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starter-zipkin2</artifactId> + <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency>

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2

    Gradle.  +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin

    Gradle. 

    dependencyManagement { 1
         imports {
             mavenBom "org.springframework.cloud:spring-cloud-dependencies:${releaseTrainVersion}"
    @@ -195,11 +195,11 @@ the Spring BOM

    2 - compile "org.springframework.cloud:spring-cloud-starter-zipkin2" + compile "org.springframework.cloud:spring-cloud-starter-zipkin" }

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2

    1.3.3 Sleuth with Zipkin via RabbitMQ or Kafka

    If you want to use RabbitMQ or Kafka instead of http, add the spring-rabbit or spring-kafka -dependencies. The default destination name is zipkin.

    Note: spring-cloud-sleuth-stream is deprecated and incompatible with these destinations

    If you want Sleuth over RabbitMQ add the spring-cloud-starter-zipkin2 and spring-rabbit +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin

    1.3.3 Sleuth with Zipkin via RabbitMQ or Kafka

    If you want to use RabbitMQ or Kafka instead of http, add the spring-rabbit or spring-kafka +dependencies. The default destination name is zipkin.

    Note: spring-cloud-sleuth-stream is deprecated and incompatible with these destinations

    If you want Sleuth over RabbitMQ add the spring-cloud-starter-zipkin and spring-rabbit dependencies.

    Maven. 

    <dependencyManagement> 1
              <dependencies>
    @@ -215,14 +215,14 @@ dependencies.

    Maven.  <dependency> 2 <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starter-zipkin2</artifactId> + <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> <dependency> 3 <groupId>org.springframework.amqp</groupId> <artifactId>spring-rabbit</artifactId> </dependency>

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2 - that way all dependent dependencies will be downloaded

    3

    To automatically configure rabbit, simply add the spring-rabbit dependency

    Gradle.  +the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded

    3

    To automatically configure rabbit, simply add the spring-rabbit dependency

    Gradle. 

    dependencyManagement { 1
         imports {
             mavenBom "org.springframework.cloud:spring-cloud-dependencies:${releaseTrainVersion}"
    @@ -230,11 +230,11 @@ the Spring BOM

    "org.springframework.cloud:spring-cloud-starter-zipkin2" 2 + compile "org.springframework.cloud:spring-cloud-starter-zipkin" 2 compile "org.springframework.amqp:spring-rabbit" 3 }

    1

    In order not to pick versions by yourself it’s much better if you add the dependency management via -the Spring BOM

    2

    Add the dependency to spring-cloud-starter-zipkin2 - that way all dependent dependencies will be downloaded

    3

    To automatically configure rabbit, simply add the spring-rabbit dependency

    2. Additional resources

    Marcin Grzejszczak talking about Spring Cloud Sleuth and Zipkin

    click here to see the video

    3. Features

    • Adds trace and span ids to the Slf4J MDC, so you can extract all the logs from a given trace or span in a log aggregator. Example logs:

      2016-02-02 15:30:57.902  INFO [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] ...
      +the Spring BOM

      2

      Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded

      3

      To automatically configure rabbit, simply add the spring-rabbit dependency

    2. Additional resources

    Marcin Grzejszczak talking about Spring Cloud Sleuth and Zipkin

    click here to see the video

    3. Features

    • Adds trace and span ids to the Slf4J MDC, so you can extract all the logs from a given trace or span in a log aggregator. Example logs:

      2016-02-02 15:30:57.902  INFO [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] ...
       2016-02-02 15:30:58.372 ERROR [bar,6bfd228dc00d216b,6bfd228dc00d216b,false] 23030 --- [nio-8081-exec-3] ...
       2016-02-02 15:31:01.936  INFO [bar,46ab0d418373cbc9,46ab0d418373cbc9,false] 23030 --- [nio-8081-exec-4] ...

      notice the [appname,traceId,spanId,exportable] entries from the MDC:

      • spanId - the id of a specific operation that took place
      • appname - the name of the application that logged the span
      • traceId - the id of the latency graph that contains the span
      • exportable - whether the log should be exported to Zipkin or not. When would you like the span not to be exportable? In the case in which you want to wrap some operation in a Span and have it written to the logs @@ -244,7 +244,7 @@ latency in your applications. Sleuth is written to not log too much, and to not rest template, scheduled actions, message channels, zuul filters, feign client).
      • Sleuth includes default logic to join a trace across http or messaging boundaries. For example, http propagation works via Zipkin-compatible request headers. This propagation logic is defined and customized via SpanInjector and SpanExtractor implementations.
      • Sleuth gives you the possibility to propagate context (also known as baggage) between processes. That means that if you set on a Span -a baggage element then it will be sent downstream either via HTTP or messaging to other processes.
      • Provides a way to create / continue spans and add tags and logs via annotations.
      • Provides simple metrics of accepted / dropped spans.
      • If spring-cloud-sleuth-zipkin2 then the app will generate and collect Zipkin-compatible traces. +a baggage element then it will be sent downstream either via HTTP or messaging to other processes.

      • Provides a way to create / continue spans and add tags and logs via annotations.
      • Provides simple metrics of accepted / dropped spans.
      • If spring-cloud-sleuth-zipkin then the app will generate and collect Zipkin-compatible traces. By default it sends them via HTTP to a Zipkin server on localhost (port 9411). Configure the location of the service using spring.zipkin.baseUrl.

        • If you depend on spring-rabbit or spring-kafka your app will send traces to a broker instead of http.
        • Note: spring-cloud-sleuth-stream is deprecated and should no longer be used.
      [Important]Important

      If using Zipkin, configure the percentage of spans exported using spring.sleuth.sampler.percentage (default 0.1, i.e. 10%). Otherwise you might think that Sleuth is not working cause it’s omitting some spans.

      [Note]Note

      the SLF4J MDC is always set and logback users will immediately see the trace and span ids in logs per the example @@ -536,20 +536,7 @@ TraceFilter myTraceFilter(BeanFactory beanFactory,

      9.5 Custom SA tag in Zipkin

      Sometimes you want to create a manual Span that will wrap a call to an external service which is not instrumented. What you can do is to create a span with the peer.service tag that will contain a value of the service that you want to call. -Below you can see an example of a call to Redis that is wrapped in such a span.

      org.springframework.cloud.sleuth.Span newSpan = tracer.createSpan("redis");
      -try {
      -	newSpan.tag("redis.op", "get");
      -	newSpan.tag("lc", "redis");
      -	newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_SEND);
      -	// call redis service e.g
      -	// return (SomeObj) redisTemplate.opsForHash().get("MYHASH", someObjKey);
      -} finally {
      -	newSpan.tag("peer.service", "redisService");
      -	newSpan.tag("peer.ipv4", "1.2.3.4");
      -	newSpan.tag("peer.port", "1234");
      -	newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_RECV);
      -	tracer.close(newSpan);
      -}
      [Important]Important

      Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

      9.6 Custom service name

      By default Sleuth assumes that when you send a span to Zipkin, you want the span’s service name +Below you can see an example of a call to Redis that is wrapped in such a span.

      Unresolved directive in spring-cloud-sleuth.adoc - include::../../../..//spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java[tags=service_name,indent=0]
      [Important]Important

      Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.

      9.6 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 spring.application.name value. That’s not always the case though. There are situations in which you want to explicitly provide a different service name for all spans coming from your application. To achieve that it’s enough to just pass the following property diff --git a/spring-cloud-sleuth.xml b/spring-cloud-sleuth.xml index 3d5d78240..007d08631 100644 --- a/spring-cloud-sleuth.xml +++ b/spring-cloud-sleuth.xml @@ -434,7 +434,7 @@ the Spring BOM

      Sleuth with Zipkin via HTTP -If you want both Sleuth and Zipkin just add the spring-cloud-starter-zipkin2 dependency. +If you want both Sleuth and Zipkin just add the spring-cloud-starter-zipkin dependency. Maven @@ -452,7 +452,7 @@ the Spring BOM <dependency> <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starter-zipkin2</artifactId> + <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> @@ -462,7 +462,7 @@ the Spring BOM the Spring BOM -Add the dependency to spring-cloud-starter-zipkin2 +Add the dependency to spring-cloud-starter-zipkin @@ -475,7 +475,7 @@ the Spring BOM } dependencies { - compile "org.springframework.cloud:spring-cloud-starter-zipkin2" + compile "org.springframework.cloud:spring-cloud-starter-zipkin" } @@ -485,7 +485,7 @@ dependencies { the Spring BOM -Add the dependency to spring-cloud-starter-zipkin2 +Add the dependency to spring-cloud-starter-zipkin
      @@ -494,7 +494,7 @@ the Spring BOM If you want to use RabbitMQ or Kafka instead of http, add the spring-rabbit or spring-kafka dependencies. The default destination name is zipkin. Note: spring-cloud-sleuth-stream is deprecated and incompatible with these destinations -If you want Sleuth over RabbitMQ add the spring-cloud-starter-zipkin2 and spring-rabbit +If you want Sleuth over RabbitMQ add the spring-cloud-starter-zipkin and spring-rabbit dependencies. Maven @@ -513,7 +513,7 @@ dependencies. <dependency> <groupId>org.springframework.cloud</groupId> - <artifactId>spring-cloud-starter-zipkin2</artifactId> + <artifactId>spring-cloud-starter-zipkin</artifactId> </dependency> <dependency> <groupId>org.springframework.amqp</groupId> @@ -527,7 +527,7 @@ dependencies. the Spring BOM -Add the dependency to spring-cloud-starter-zipkin2 - that way all dependent dependencies will be downloaded +Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded To automatically configure rabbit, simply add the spring-rabbit dependency @@ -543,7 +543,7 @@ the Spring BOM } dependencies { - compile "org.springframework.cloud:spring-cloud-starter-zipkin2" + compile "org.springframework.cloud:spring-cloud-starter-zipkin" compile "org.springframework.amqp:spring-rabbit" } @@ -554,7 +554,7 @@ dependencies { the Spring BOM -Add the dependency to spring-cloud-starter-zipkin2 - that way all dependent dependencies will be downloaded +Add the dependency to spring-cloud-starter-zipkin - that way all dependent dependencies will be downloaded To automatically configure rabbit, simply add the spring-rabbit dependency @@ -637,7 +637,7 @@ a baggage element then it will be sent downstream either via HTTP or messaging t Provides simple metrics of accepted / dropped spans. -If spring-cloud-sleuth-zipkin2 then the app will generate and collect Zipkin-compatible traces. +If spring-cloud-sleuth-zipkin then the app will generate and collect Zipkin-compatible traces. By default it sends them via HTTP to a Zipkin server on localhost (port 9411). Configure the location of the service using spring.zipkin.baseUrl. @@ -1233,20 +1233,7 @@ TraceFilter myTraceFilter(BeanFactory beanFactory, final Tracer tracer) { Sometimes you want to create a manual Span that will wrap a call to an external service which is not instrumented. What you can do is to create a span with the peer.service tag that will contain a value of the service that you want to call. Below you can see an example of a call to Redis that is wrapped in such a span. -org.springframework.cloud.sleuth.Span newSpan = tracer.createSpan("redis"); -try { - newSpan.tag("redis.op", "get"); - newSpan.tag("lc", "redis"); - newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_SEND); - // call redis service e.g - // return (SomeObj) redisTemplate.opsForHash().get("MYHASH", someObjKey); -} finally { - newSpan.tag("peer.service", "redisService"); - newSpan.tag("peer.ipv4", "1.2.3.4"); - newSpan.tag("peer.port", "1234"); - newSpan.logEvent(org.springframework.cloud.sleuth.Span.CLIENT_RECV); - tracer.close(newSpan); -} +Unresolved directive in spring-cloud-sleuth.adoc - include::../../../..//spring-cloud-sleuth-zipkin/src/test/java/org/springframework/cloud/sleuth/zipkin/HttpZipkinSpanReporterTest.java[tags=service_name,indent=0] Remember not to add both peer.service tag and the SA tag! You have to add only peer.service.