Added back the baggage docs
This commit is contained in:
@@ -183,6 +183,48 @@ include::https://raw.githubusercontent.com/spring-cloud-samples/sleuth-documenta
|
||||
NOTE: If you're using a custom `logback-spring.xml` then you have to pass the `spring.application.name` in
|
||||
`bootstrap` instead of `application` property file. Otherwise your custom logback file won't read the property properly.
|
||||
|
||||
==== Propagating Span Context
|
||||
|
||||
The span context is the state that must get propagated to any child Spans across process boundaries.
|
||||
Part of the Span Context is the Baggage. The trace and span IDs are a required part of the span context.
|
||||
Baggage is an optional part.
|
||||
|
||||
Baggage is a set of key:value pairs stored in the span context. Baggage travels together with the trace
|
||||
and is attached to every span. Spring Cloud Sleuth will understand that a header is baggage related if the HTTP
|
||||
header is prefixed with `baggage-` and for messaging it starts with `baggage_`.
|
||||
|
||||
IMPORTANT: There's currently no limitation of the count or size of baggage items. However, keep in mind that
|
||||
too many can decrease system throughput or increase RPC latency. In extreme cases, it could crash the app due
|
||||
to exceeding transport-level message or header capacity.
|
||||
|
||||
Example of setting baggage on a span:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
include::{github-raw}/spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/multiple/MultipleHopsIntegrationTests.java[tags=baggage,indent=0]
|
||||
----
|
||||
|
||||
===== Baggage vs. Span Tags
|
||||
|
||||
Baggage travels with the trace (i.e. every child span contains the baggage of its parent). Zipkin has no knowledge of
|
||||
baggage and will not even receive that information.
|
||||
|
||||
Tags are attached to a specific span - they are presented for that particular span only. However you
|
||||
can search by tag to find the trace, where there exists a span having the searched tag value.
|
||||
|
||||
If you want to be able to lookup a span based on baggage, you should add corresponding entry as a tag in the root span.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@Autowired Tracer tracer;
|
||||
|
||||
Span span = tracer.getCurrentSpan();
|
||||
String baggageKey = "key";
|
||||
String baggageValue = "foo";
|
||||
span.setBaggageItem(baggageKey, baggageValue);
|
||||
tracer.addTag(baggageKey, baggageValue);
|
||||
----
|
||||
|
||||
=== Adding to the project
|
||||
|
||||
==== Only Sleuth (log correlation)
|
||||
@@ -198,7 +240,7 @@ the `spring-cloud-starter-sleuth` module to your project.
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Brixton.RELEASE</version>
|
||||
<version>Camden.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -219,7 +261,7 @@ the Spring BOM
|
||||
----
|
||||
dependencyManagement { <1>
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE"
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +285,7 @@ If you want both Sleuth and Zipkin just add the `spring-cloud-starter-zipkin` de
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Brixton.RELEASE</version>
|
||||
<version>Camden.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -264,7 +306,7 @@ the Spring BOM
|
||||
----
|
||||
dependencyManagement { <1>
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE"
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,7 +330,7 @@ If you want both Sleuth and Zipkin just add the `spring-cloud-sleuth-stream` dep
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Brixton.RELEASE</version>
|
||||
<version>Camden.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -320,7 +362,7 @@ the Spring BOM
|
||||
----
|
||||
dependencyManagement { <1>
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE"
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +392,7 @@ dependency
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Brixton.RELEASE</version>
|
||||
<version>Camden.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -382,7 +424,7 @@ the Spring BOM
|
||||
----
|
||||
dependencyManagement { <1>
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Brixton.RELEASE"
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user