@@ -11,6 +11,36 @@ public interface TraceScope extends Closeable {
11
11
@ Override
12
12
void close ();
13
13
14
+ /**
15
+ * Used to pass async context between workers. A trace will not be reported until all spans and
16
+ * continuations are resolved. You must call activate (and close on the returned scope) or cancel
17
+ * on each continuation to avoid discarding traces.
18
+ */
19
+ interface Continuation {
20
+
21
+ /**
22
+ * Prevent the trace attached to this scope from reporting until the continuation is explicitly
23
+ * cancelled. You must call {@link #cancel()} at some point to avoid discarding traces.
24
+ *
25
+ * <p>Use this when you want to let multiple threads activate the continuation concurrently and
26
+ * close their scopes without fear of prematurely closing the related span.
27
+ */
28
+ Continuation hold ();
29
+
30
+ /**
31
+ * Activate the continuation.
32
+ *
33
+ * <p>Should be called on the child thread.
34
+ *
35
+ * <p>Consider calling this in a try-with-resources initialization block to ensure the returned
36
+ * scope is closed properly.
37
+ */
38
+ TraceScope activate ();
39
+
40
+ /** Allow trace to stop waiting on this continuation for reporting. */
41
+ void cancel ();
42
+ }
43
+
14
44
/**
15
45
* @deprecated Replaced by {@link Tracer#captureActiveSpan()}.
16
46
* <p>Prevent the <strong>currently active trace</strong>, which may differ from this scope
@@ -51,34 +81,4 @@ default boolean isAsyncPropagating() {
51
81
default void setAsyncPropagation (boolean value ) {
52
82
GlobalTracer .get ().setAsyncPropagationEnabled (value );
53
83
}
54
-
55
- /**
56
- * Used to pass async context between workers. A trace will not be reported until all spans and
57
- * continuations are resolved. You must call activate (and close on the returned scope) or cancel
58
- * on each continuation to avoid discarding traces.
59
- */
60
- interface Continuation {
61
-
62
- /**
63
- * Prevent the trace attached to this scope from reporting until the continuation is explicitly
64
- * cancelled. You must call {@link #cancel()} at some point to avoid discarding traces.
65
- *
66
- * <p>Use this when you want to let multiple threads activate the continuation concurrently and
67
- * close their scopes without fear of prematurely closing the related span.
68
- */
69
- Continuation hold ();
70
-
71
- /**
72
- * Activate the continuation.
73
- *
74
- * <p>Should be called on the child thread.
75
- *
76
- * <p>Consider calling this in a try-with-resources initialization block to ensure the returned
77
- * scope is closed properly.
78
- */
79
- TraceScope activate ();
80
-
81
- /** Allow trace to stop waiting on this continuation for reporting. */
82
- void cancel ();
83
- }
84
84
}
0 commit comments