Simplified Tracer API
This commit is contained in:
@@ -73,7 +73,7 @@ The span is also removed from the current thread.
|
||||
- <<continuing-spans, continue>> - a new instance of span will be created whereas it will be a copy of the
|
||||
one that it continues.
|
||||
- <<continuing-spans, detach>> - the span doesn't get stopped or closed. It only gets removed from the current thread.
|
||||
- <<joining-spans, join>> - you can create a new span and set an explicit parent to it
|
||||
- <<creating-spans-with-explicit-parent, create with explicit parent>> - you can create a new span and set an explicit parent to it
|
||||
|
||||
=== Creating and closing spans [[creating-and-closing-spans]]
|
||||
|
||||
@@ -117,18 +117,18 @@ IMPORTANT: Always clean after you create a span! Don't forget to detach a span i
|
||||
Then the spans in the threads Y, Z should be detached at the end of their work. When the results are collected
|
||||
the span in thread X should be closed.
|
||||
|
||||
=== Joining spans [[joining-spans]]
|
||||
=== Creating spans with an explicit parent [[creating-spans-with-explicit-parent]]
|
||||
|
||||
There is a possibility that you want to start a new span and provide an explicit parent of that span.
|
||||
Let's assume that the parent of a span is in one thread and you want to start a new span in another thread. The
|
||||
`joinTrace` method of the `Tracer` interface is the method you are looking for.
|
||||
`startSpan` method of the `Tracer` interface is the method you are looking for.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
include::../../../../spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/documentation/SpringCloudSleuthDocTests.java[tags=manual_span_joining,indent=0]
|
||||
----
|
||||
|
||||
IMPORTANT: After having joined the span remember to close it. Otherwise you will see a lot of warnings in your logs
|
||||
IMPORTANT: After having created such a span remember to close it. Otherwise you will see a lot of warnings in your logs
|
||||
related to the fact that you have a span present in the current thread other than the one you're trying to close.
|
||||
What's worse your spans won't get closed properly thus will not get collected to Zipkin.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user