From fa054850ff348f15187707b5d40f0a4ed2e73c89 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 4 Jun 2018 08:47:17 +0200 Subject: [PATCH] Added docs related to traceid string; fixes gh-998 --- docs/src/main/asciidoc/spring-cloud-sleuth.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/src/main/asciidoc/spring-cloud-sleuth.adoc b/docs/src/main/asciidoc/spring-cloud-sleuth.adoc index fdf308789..6f29c112f 100644 --- a/docs/src/main/asciidoc/spring-cloud-sleuth.adoc +++ b/docs/src/main/asciidoc/spring-cloud-sleuth.adoc @@ -480,6 +480,11 @@ Instead, look them up each time you need them. 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.