diff --git a/README.adoc b/README.adoc index 6d0814a03..fca6934f5 100644 --- a/README.adoc +++ b/README.adoc @@ -4,6 +4,7 @@ Manual changes to this file will be lost when it is generated again. Edit the files in the src/main/asciidoc/ directory instead. //// + :jdkversion: 1.8 :github-tag: master :github-repo: spring-cloud/spring-cloud-sleuth @@ -93,9 +94,11 @@ Each color of a note signifies a span (there are seven spans - from *A* to *G*). Consider the following note: [source] +---- Trace Id = X Span Id = D Client Sent +---- This note indicates that the current span has *Trace Id* set to *X* and *Span Id* set to *D*. Also, the `Client Sent` event took place. @@ -189,6 +192,7 @@ https://docssleuth-zipkin-server.cfapps.io/dependency[Click here to see it live! When using grep to read the logs of those four applications by scanning for a trace ID equal to (for example) `2485ec27856c56f4`, you get output resembling the following: [source] +---- service1.log:2016-02-26 11:15:47.561 INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application : Hello from service1. Calling service2 service2.log:2016-02-26 11:15:47.710 INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio-8082-exec-1] i.s.c.sleuth.docs.service2.Application : Hello from service2. Calling service3 and then service4 service3.log:2016-02-26 11:15:47.895 INFO [service3,2485ec27856c56f4,1210be13194bfe5,true] 68060 --- [nio-8083-exec-1] i.s.c.sleuth.docs.service3.Application : Hello from service3 @@ -196,6 +200,7 @@ service2.log:2016-02-26 11:15:47.924 INFO [service2,2485ec27856c56f4,9aa10ee6fb service4.log:2016-02-26 11:15:48.134 INFO [service4,2485ec27856c56f4,1b1845262ffba49d,true] 68061 --- [nio-8084-exec-1] i.s.c.sleuth.docs.service4.Application : Hello from service4 service2.log:2016-02-26 11:15:48.156 INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio-8082-exec-1] i.s.c.sleuth.docs.service2.Application : Got response from service4 [Hello from service4] service1.log:2016-02-26 11:15:48.182 INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application : Got response from service2 [Hello from service2, response from service3 [Hello from service3] and from service4 [Hello from service4]] +---- If you use a log aggregating tool (such as https://www.elastic.co/products/kibana[Kibana], https://www.splunk.com/[Splunk], and others), you can order the events that took place. An example from Kibana would resemble the following image: @@ -205,6 +210,7 @@ image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/{branc If you want to use https://www.elastic.co/guide/en/logstash/current/index.html[Logstash], the following listing shows the Grok pattern for Logstash: [source] +---- filter { # pattern matching logback pattern grok { @@ -217,9 +223,11 @@ filter { remove_field => ["timestamp"] } } +---- NOTE: If you want to use Grok together with the logs from Cloud Foundry, you have to use the following pattern: [source] +---- filter { # pattern matching logback pattern grok { @@ -232,6 +240,7 @@ filter { remove_field => ["timestamp"] } } +---- ===== JSON Logback with Logstash @@ -248,84 +257,83 @@ To do so, you have to do the following (for readability, we pass the dependencie Consider the following example of a Logback configuration file (named https://github.com/spring-cloud-samples/sleuth-documentation-apps/blob/master/service1/src/main/resources/logback-spring.xml[logback-spring.xml]). [source,xml] ------ +---- - - ​ - - - ​ + + ​ + + + ​ - - + + - - - - - DEBUG - - - ${CONSOLE_LOG_PATTERN} - utf8 - - + + + + + DEBUG + + + ${CONSOLE_LOG_PATTERN} + utf8 + + - ​ - - ${LOG_FILE} - - ${LOG_FILE}.%d{yyyy-MM-dd}.gz - 7 - - - ${CONSOLE_LOG_PATTERN} - utf8 - - - ​ - - - ${LOG_FILE}.json - - ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz - 7 - - - - - UTC - - - - { - "severity": "%level", - "service": "${springAppName:-}", - "trace": "%X{X-B3-TraceId:-}", - "span": "%X{X-B3-SpanId:-}", - "parent": "%X{X-B3-ParentSpanId:-}", - "exportable": "%X{X-Span-Export:-}", - "pid": "${PID:-}", - "thread": "%thread", - "class": "%logger{40}", - "rest": "%message" - } - - - - - - ​ - - - - - - + ​ + + ${LOG_FILE} + + ${LOG_FILE}.%d{yyyy-MM-dd}.gz + 7 + + + ${CONSOLE_LOG_PATTERN} + utf8 + + + ​ + + + ${LOG_FILE}.json + + ${LOG_FILE}.json.%d{yyyy-MM-dd}.gz + 7 + + + + + UTC + + + + { + "severity": "%level", + "service": "${springAppName:-}", + "trace": "%X{traceId:-}", + "span": "%X{spanId:-}", + "baggage": "%X{key:-}", + "pid": "${PID:-}", + "thread": "%thread", + "class": "%logger{40}", + "rest": "%message" + } + + + + + + ​ + + + + + + ------ +---- That Logback configuration file: @@ -392,9 +400,9 @@ spring.sleuth: [source,java] ---- initialSpan.tag("foo", - ExtraFieldPropagation.get(initialSpan.context(), "foo")); + ExtraFieldPropagation.get(initialSpan.context(), "foo")); initialSpan.tag("UPPER_CASE", - ExtraFieldPropagation.get(initialSpan.context(), "UPPER_CASE")); + ExtraFieldPropagation.get(initialSpan.context(), "UPPER_CASE")); ---- [[sleuth-adding-project]] @@ -410,8 +418,8 @@ If you want to use only Spring Cloud Sleuth without the Zipkin integration, add The following example shows how to add Sleuth with Maven: -[source,xml,indent=0,subs="verbatim,attributes",role="primary"] .Maven +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] ---- <1> @@ -435,8 +443,8 @@ The following example shows how to add Sleuth with Maven: The following example shows how to add Sleuth with Gradle: -[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] .Gradle +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] ---- dependencyManagement { <1> imports { @@ -457,8 +465,8 @@ If you want both Sleuth and Zipkin, add the `spring-cloud-starter-zipkin` depend The following example shows how to do so for Maven: -[source,xml,indent=0,subs="verbatim,attributes",role="primary"] .Maven +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] ---- <1> @@ -482,8 +490,8 @@ The following example shows how to do so for Maven: The following example shows how to do so for Gradle: -[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] .Gradle +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] ---- dependencyManagement { <1> imports { @@ -517,8 +525,8 @@ dependencies. The following example shows how to do so for Gradle: -[source,xml,indent=0,subs="verbatim,attributes",role="primary"] .Maven +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] ---- <1> @@ -545,8 +553,8 @@ The following example shows how to do so for Gradle: <2> Add the dependency to `spring-cloud-starter-zipkin`. That way, all nested dependencies get downloaded. <3> To automatically configure RabbitMQ, add the `spring-rabbit` dependency. -[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] .Gradle +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] ---- dependencyManagement { <1> imports { @@ -576,46 +584,46 @@ To do this you can use respectively `ZipkinAutoConfiguration.REPORTER_BEAN_NAME` @Configuration protected static class MyConfig { - @Bean(ZipkinAutoConfiguration.REPORTER_BEAN_NAME) - Reporter myReporter() { - return AsyncReporter.create(mySender()); - } + @Bean(ZipkinAutoConfiguration.REPORTER_BEAN_NAME) + Reporter myReporter() { + return AsyncReporter.create(mySender()); + } - @Bean(ZipkinAutoConfiguration.SENDER_BEAN_NAME) - MySender mySender() { - return new MySender(); - } + @Bean(ZipkinAutoConfiguration.SENDER_BEAN_NAME) + MySender mySender() { + return new MySender(); + } - static class MySender extends Sender { + static class MySender extends Sender { - private boolean spanSent = false; + private boolean spanSent = false; - boolean isSpanSent() { - return this.spanSent; - } + boolean isSpanSent() { + return this.spanSent; + } - @Override - public Encoding encoding() { - return Encoding.JSON; - } + @Override + public Encoding encoding() { + return Encoding.JSON; + } - @Override - public int messageMaxBytes() { - return Integer.MAX_VALUE; - } + @Override + public int messageMaxBytes() { + return Integer.MAX_VALUE; + } - @Override - public int messageSizeInBytes(List encodedSpans) { - return encoding().listSizeInBytes(encodedSpans); - } + @Override + public int messageSizeInBytes(List encodedSpans) { + return encoding().listSizeInBytes(encodedSpans); + } - @Override - public Call sendSpans(List encodedSpans) { - this.spanSent = true; - return Call.create(null); - } + @Override + public Call sendSpans(List encodedSpans) { + this.spanSent = true; + return Call.create(null); + } - } + } } @@ -768,6 +776,11 @@ https://eclipse.org[Eclipse] when working with the code. We use the https://eclipse.org/m2e/[m2eclipse] eclipse plugin for maven support. Other IDEs and tools should also work without issue as long as they use Maven 3.3.3 or better. +==== Activate the Spring Maven profile +Spring Cloud projects require the 'spring' Maven profile to be activated to resolve +the spring milestone and snapshot repositories. Use your preferred IDE to set this +profile to be active, or you may experience build errors. + ==== Importing into eclipse with m2eclipse We recommend the https://eclipse.org/m2e/[m2eclipse] eclipse plugin when working with eclipse. If you don't already have m2eclipse installed it is available from the "eclipse @@ -888,6 +901,7 @@ Checkstyle rules are *disabled by default*. To add checkstyle to your project ju spring-javaformat-maven-plugin <5> + org.apache.maven.plugins maven-checkstyle-plugin @@ -895,6 +909,7 @@ Checkstyle rules are *disabled by default*. To add checkstyle to your project ju <5> + org.apache.maven.plugins maven-checkstyle-plugin @@ -978,4 +993,4 @@ Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on t - `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL. - `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`. -IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. \ No newline at end of file +IMPORTANT: Remember to set the `Scan Scope` to `All sources` since we apply checkstyle rules for production and test sources. diff --git a/docs/pom.xml b/docs/pom.xml index d81f02733..b8b977cfb 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -30,10 +30,9 @@ Spring Sleuth Docs spring-cloud-sleuth - - 2.1.x,2.2.x ${basedir}/.. spring.sleuth.*|spring.zipkin.* + deploy @@ -71,6 +70,9 @@ maven-antrun-plugin + + maven-deploy-plugin + diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index 1fe0eef0f..07d281a19 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -12,11 +12,11 @@ |spring.sleuth.feign.processor.enabled | true | Enable post processor that wraps Feign Context in its tracing representations. |spring.sleuth.grpc.enabled | true | Enable span information propagation when using GRPC. |spring.sleuth.http.enabled | true | -|spring.sleuth.http.legacy.enabled | false | Enables the legacy Sleuth setup. +|spring.sleuth.http.legacy.enabled | false | |spring.sleuth.hystrix.strategy.enabled | true | Enable custom HystrixConcurrencyStrategy that wraps all Callable instances into their Sleuth representative - the TraceCallable. |spring.sleuth.hystrix.strategy.passthrough | false | When enabled the tracing information is passed to the Hystrix execution threads but spans are not created for each execution. |spring.sleuth.integration.enabled | true | Enable Spring Integration sleuth instrumentation. -|spring.sleuth.integration.patterns | [!hystrixStreamOutput*, *] | An array of patterns against which channel names will be matched. @see org.springframework.integration.config.GlobalChannelInterceptor#patterns() Defaults to any channel name not matching the Hystrix Stream channel name. +|spring.sleuth.integration.patterns | [!hystrixStreamOutput*, *, !channel*] | An array of patterns against which channel names will be matched. @see org.springframework.integration.config.GlobalChannelInterceptor#patterns() Defaults to any channel name not matching the Hystrix Stream and functional Stream channel names. |spring.sleuth.integration.websockets.enabled | true | Enable tracing for WebSockets. |spring.sleuth.keys.http.headers | | Additional headers that should be added as tags if they exist. If the header value is multi-valued, the tag value will be a comma-separated, single-quoted list. |spring.sleuth.keys.http.prefix | http. | Prefix for header names if they are added as tags. @@ -33,12 +33,13 @@ |spring.sleuth.messaging.rabbit.remote-service-name | rabbitmq | |spring.sleuth.opentracing.enabled | true | |spring.sleuth.propagation-keys | | List of fields that are referenced the same in-process as it is on the wire. For example, the name "x-vcap-request-id" would be set as-is including the prefix.

Note: {@code fieldName} will be implicitly lower-cased. @see brave.propagation.ExtraFieldPropagation.FactoryBuilder#addField(String) -|spring.sleuth.propagation.tag.enabled | true | Enables a {@link TagPropagationSpanHandler} that adds extra propagated fields to span tags. +|spring.sleuth.propagation.tag.enabled | true | Enables a {@link TagPropagationFinishedSpanHandler} that adds extra propagated fields to span tags. |spring.sleuth.propagation.tag.whitelisted-keys | | A list of keys to be put from extra propagation fields to span tags. |spring.sleuth.reactor.decorate-on-each | true | When true decorates on each operator, will be less performing, but logging will always contain the tracing entries in each operator. When false decorates on last operator, will be more performing, but logging might not always contain the tracing entries. |spring.sleuth.reactor.enabled | true | When true enables instrumentation for reactor. |spring.sleuth.redis.enabled | true | Enable span information propagation when using Redis. |spring.sleuth.redis.remote-service-name | redis | Service name for the remote Redis endpoint. +|spring.sleuth.rpc.enabled | true | Enable tracing of RPC. |spring.sleuth.rxjava.schedulers.hook.enabled | true | Enable support for RxJava via RxJavaSchedulersHook. |spring.sleuth.rxjava.schedulers.ignoredthreads | [HystrixMetricPoller, ^RxComputation.*$] | Thread names for which spans will not be sampled. |spring.sleuth.sampler.probability | | Probability of requests that should be sampled. E.g. 1.0 - 100% requests should be sampled. The precision is whole-numbers only (i.e. there's no support for 0.1% of the traces). @@ -72,4 +73,4 @@ |spring.zipkin.sender.type | | Means of sending spans to Zipkin. |spring.zipkin.service.name | | The name of the service, from which the Span was sent via HTTP, that should appear in Zipkin. -|=== +|=== \ No newline at end of file diff --git a/docs/src/main/asciidoc/intro.adoc b/docs/src/main/asciidoc/intro.adoc index 0919c28d9..5ecf7ace9 100644 --- a/docs/src/main/asciidoc/intro.adoc +++ b/docs/src/main/asciidoc/intro.adoc @@ -45,9 +45,11 @@ Each color of a note signifies a span (there are seven spans - from *A* to *G*). Consider the following note: [source] +---- Trace Id = X Span Id = D Client Sent +---- This note indicates that the current span has *Trace Id* set to *X* and *Span Id* set to *D*. Also, the `Client Sent` event took place. @@ -141,6 +143,7 @@ https://docssleuth-zipkin-server.cfapps.io/dependency[Click here to see it live! When using grep to read the logs of those four applications by scanning for a trace ID equal to (for example) `2485ec27856c56f4`, you get output resembling the following: [source] +---- service1.log:2016-02-26 11:15:47.561 INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application : Hello from service1. Calling service2 service2.log:2016-02-26 11:15:47.710 INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio-8082-exec-1] i.s.c.sleuth.docs.service2.Application : Hello from service2. Calling service3 and then service4 service3.log:2016-02-26 11:15:47.895 INFO [service3,2485ec27856c56f4,1210be13194bfe5,true] 68060 --- [nio-8083-exec-1] i.s.c.sleuth.docs.service3.Application : Hello from service3 @@ -148,6 +151,7 @@ service2.log:2016-02-26 11:15:47.924 INFO [service2,2485ec27856c56f4,9aa10ee6fb service4.log:2016-02-26 11:15:48.134 INFO [service4,2485ec27856c56f4,1b1845262ffba49d,true] 68061 --- [nio-8084-exec-1] i.s.c.sleuth.docs.service4.Application : Hello from service4 service2.log:2016-02-26 11:15:48.156 INFO [service2,2485ec27856c56f4,9aa10ee6fbde75fa,true] 68059 --- [nio-8082-exec-1] i.s.c.sleuth.docs.service2.Application : Got response from service4 [Hello from service4] service1.log:2016-02-26 11:15:48.182 INFO [service1,2485ec27856c56f4,2485ec27856c56f4,true] 68058 --- [nio-8081-exec-1] i.s.c.sleuth.docs.service1.Application : Got response from service2 [Hello from service2, response from service3 [Hello from service3] and from service4 [Hello from service4]] +---- If you use a log aggregating tool (such as https://www.elastic.co/products/kibana[Kibana], https://www.splunk.com/[Splunk], and others), you can order the events that took place. An example from Kibana would resemble the following image: @@ -157,6 +161,7 @@ image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-sleuth/{branc If you want to use https://www.elastic.co/guide/en/logstash/current/index.html[Logstash], the following listing shows the Grok pattern for Logstash: [source] +---- filter { # pattern matching logback pattern grok { @@ -169,9 +174,11 @@ filter { remove_field => ["timestamp"] } } +---- NOTE: If you want to use Grok together with the logs from Cloud Foundry, you have to use the following pattern: [source] +---- filter { # pattern matching logback pattern grok { @@ -184,6 +191,7 @@ filter { remove_field => ["timestamp"] } } +---- ===== JSON Logback with Logstash @@ -200,9 +208,9 @@ To do so, you have to do the following (for readability, we pass the dependencie Consider the following example of a Logback configuration file (named https://github.com/spring-cloud-samples/sleuth-documentation-apps/blob/master/service1/src/main/resources/logback-spring.xml[logback-spring.xml]). [source,xml] ------ +---- include::https://raw.githubusercontent.com/spring-cloud-samples/sleuth-documentation-apps/master/service1/src/main/resources/logback-spring.xml[] ------ +---- That Logback configuration file: @@ -276,8 +284,8 @@ If you want to use only Spring Cloud Sleuth without the Zipkin integration, add The following example shows how to add Sleuth with Maven: -[source,xml,indent=0,subs="verbatim,attributes",role="primary"] .Maven +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] ---- <1> @@ -301,8 +309,8 @@ The following example shows how to add Sleuth with Maven: The following example shows how to add Sleuth with Gradle: -[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] .Gradle +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] ---- dependencyManagement { <1> imports { @@ -323,8 +331,8 @@ If you want both Sleuth and Zipkin, add the `spring-cloud-starter-zipkin` depend The following example shows how to do so for Maven: -[source,xml,indent=0,subs="verbatim,attributes",role="primary"] .Maven +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] ---- <1> @@ -348,8 +356,8 @@ The following example shows how to do so for Maven: The following example shows how to do so for Gradle: -[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] .Gradle +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] ---- dependencyManagement { <1> imports { @@ -383,8 +391,8 @@ dependencies. The following example shows how to do so for Gradle: -[source,xml,indent=0,subs="verbatim,attributes",role="primary"] .Maven +[source,xml,indent=0,subs="verbatim,attributes",role="primary"] ---- <1> @@ -411,8 +419,8 @@ The following example shows how to do so for Gradle: <2> Add the dependency to `spring-cloud-starter-zipkin`. That way, all nested dependencies get downloaded. <3> To automatically configure RabbitMQ, add the `spring-rabbit` dependency. -[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] .Gradle +[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"] ---- dependencyManagement { <1> imports { diff --git a/pom.xml b/pom.xml index 9266d5be3..4d13fec04 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.springframework.cloud spring-cloud-build - 2.3.0.RELEASE + 2.3.1.BUILD-SNAPSHOT