diff --git a/multi/multi__current_span.html b/multi/multi__current_span.html index 53cf03a39..f5c500ef8 100644 --- a/multi/multi__current_span.html +++ b/multi/multi__current_span.html @@ -1,7 +1,10 @@ 7. Current Span

7. Current Span

Brave supports a "current span" concept which represents the in-flight operation. -You can use Tracer.currentSpan() to add custom tags to a span and Tracer.nextSpan() to create a child of whatever is in-flight.

7.1 Setting a span in scope manually

When writing new instrumentation, it is important to place a span you created in scope as the current span. +You can use Tracer.currentSpan() to add custom tags to a span and Tracer.nextSpan() to create a child of whatever is in-flight.

In Sleuth, you can autowire the Tracer bean to retrieve the current span via +tracer.currentSpan() method. To retrieve the current context just call +tracer.currentSpan().context(). To get the current trace id as String +you can use the traceIdString() method like this: tracer.currentSpan().context().traceIdString().

7.1 Setting a span in scope manually

When writing new instrumentation, it is important to place a span you created in scope as the current span. Not only does doing so let users access it with Tracer.currentSpan(), but it also allows customizations such as SLF4J MDC to see the current trace IDs.

Tracer.withSpanInScope(Span) facilitates this and is most conveniently employed by using the try-with-resources idiom. Whenever external code might be invoked (such as proceeding an interceptor or otherwise), place the span in scope, as shown in the following example:

try (SpanInScope ws = tracer.withSpanInScope(span)) {
   return inboundRequest.invoke();
diff --git a/single/spring-cloud-sleuth.html b/single/spring-cloud-sleuth.html
index 50ea53105..d41a68467 100644
--- a/single/spring-cloud-sleuth.html
+++ b/single/spring-cloud-sleuth.html
@@ -463,7 +463,10 @@ This was made for JDBC connections, as they often initialize prior to the tracin
 You can also use Tracing.currentTracer() to get only the tracer.
 If you use either of these methods, do not cache the result.
 Instead, look them up each time you need them.

7. Current Span

Brave supports a "current span" concept which represents the in-flight operation. -You can use Tracer.currentSpan() to add custom tags to a span and Tracer.nextSpan() to create a child of whatever is in-flight.

7.1 Setting a span in scope manually

When writing new instrumentation, it is important to place a span you created in scope as the current span. +You can use Tracer.currentSpan() to add custom tags to a span and Tracer.nextSpan() to create a child of whatever is in-flight.

In Sleuth, you can autowire the Tracer bean to retrieve the current span via +tracer.currentSpan() method. To retrieve the current context just call +tracer.currentSpan().context(). To get the current trace id as String +you can use the traceIdString() method like this: tracer.currentSpan().context().traceIdString().

7.1 Setting a span in scope manually

When writing new instrumentation, it is important to place a span you created in scope as the current span. Not only does doing so let users access it with Tracer.currentSpan(), but it also allows customizations such as SLF4J MDC to see the current trace IDs.

Tracer.withSpanInScope(Span) facilitates this and is most conveniently employed by using the try-with-resources idiom. Whenever external code might be invoked (such as proceeding an interceptor or otherwise), place the span in scope, as shown in the following example:

try (SpanInScope ws = tracer.withSpanInScope(span)) {
   return inboundRequest.invoke();
diff --git a/spring-cloud-sleuth.xml b/spring-cloud-sleuth.xml
index 36fc0df3b..efca9089d 100644
--- a/spring-cloud-sleuth.xml
+++ b/spring-cloud-sleuth.xml
@@ -1055,6 +1055,10 @@ Instead, look them up each time you need them.
 Current Span
 Brave supports a "current span" concept which represents the in-flight operation.
 You can use Tracer.currentSpan() to add custom tags to a span and Tracer.nextSpan() to create a child of whatever is in-flight.
+In Sleuth, you can autowire the Tracer bean to retrieve the current span via
+tracer.currentSpan() method. To retrieve the current context just call
+tracer.currentSpan().context(). To get the current trace id as String
+you can use the traceIdString() method like this: tracer.currentSpan().context().traceIdString().
 
Setting a span in scope manually When writing new instrumentation, it is important to place a span you created in scope as the current span.