Skip to content

Commit bc105af

Browse files
author
Andrew Kent
committed
Doc PendingTrace's root span.
1 parent 29b9da5 commit bc105af

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

dd-trace-ot/src/main/java/datadog/opentracing/PendingTrace.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public class PendingTrace extends ConcurrentLinkedDeque<DDSpan> {
4040
Collections.newSetFromMap(new ConcurrentHashMap<WeakReference<?>, Boolean>());
4141

4242
private final AtomicInteger pendingReferenceCount = new AtomicInteger(0);
43+
/**
44+
* During a trace there are cases where the root span must be accessed (e.g. priority sampling and
45+
* trace-search tags).
46+
*
47+
* <p>Use a weak ref because we still need to handle buggy cases where the root span is not
48+
* correctly closed (see SpanCleaner).
49+
*
50+
* <p>The root span will be available in non-buggy cases because it has either finished and
51+
* strongly ref'd in this queue or is unfinished and ref'd in a ContinuableScope.
52+
*/
4353
private final AtomicReference<WeakReference<DDSpan>> rootSpan = new AtomicReference<>();
4454

4555
/** Ensure a trace is never written multiple times */

0 commit comments

Comments
 (0)