Span initialSpan = this.tracer.createSpan("span");
+initialSpan.setBaggageItem("foo", "bar");
+diff --git a/spring-cloud-sleuth.html b/spring-cloud-sleuth.html index df2e1156e..24b9c0c9d 100644 --- a/spring-cloud-sleuth.html +++ b/spring-cloud-sleuth.html @@ -438,6 +438,11 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
logback-spring.xml then you have to
+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:
+Span initialSpan = this.tracer.createSpan("span");
+initialSpan.setBaggageItem("foo", "bar");
+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.
+@Autowired Tracer tracer;
+
+Span span = tracer.getCurrentSpan();
+String baggageKey = "key";
+String baggageValue = "foo";
+span.setBaggageItem(baggageKey, baggageValue);
+tracer.addTag(baggageKey, baggageValue);
+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>
@@ -981,7 +1047,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"
}
}
@@ -1015,7 +1081,7 @@ the Spring BOM
<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>
@@ -1044,7 +1110,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"
}
}
@@ -1078,7 +1144,7 @@ the Spring BOM
<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>
@@ -1122,7 +1188,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"
}
}
@@ -1166,7 +1232,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>
@@ -1210,7 +1276,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"
}
}