1
1
package datadog .trace .instrumentation .rxjava ;
2
2
3
3
import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .activateSpan ;
4
- import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .capture ;
4
+ import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .activeSpan ;
5
5
import static datadog .trace .bootstrap .instrumentation .api .AgentTracer .startSpan ;
6
6
7
7
import datadog .trace .bootstrap .instrumentation .api .AgentScope ;
@@ -15,7 +15,7 @@ public class TracedOnSubscribe<T> implements Observable.OnSubscribe<T> {
15
15
16
16
private final Observable .OnSubscribe <?> delegate ;
17
17
private final CharSequence operationName ;
18
- private final AgentScope . Continuation continuation ;
18
+ private final AgentSpan parent ;
19
19
private final BaseDecorator decorator ;
20
20
21
21
public TracedOnSubscribe (
@@ -25,25 +25,15 @@ public TracedOnSubscribe(
25
25
delegate = DDTracingUtil .extractOnSubscribe (originalObservable );
26
26
this .operationName = operationName ;
27
27
this .decorator = decorator ;
28
-
29
- continuation = capture ();
28
+ this .parent = activeSpan ();
30
29
}
31
30
32
31
@ Override
33
32
public void call (final Subscriber <? super T > subscriber ) {
34
- final AgentSpan span ; // span finished by TracedSubscriber
35
- if (continuation != null ) {
36
- try (final AgentScope scope = continuation .activate ()) {
37
- span = startSpan (operationName );
38
- }
39
- } else {
40
- span = startSpan (operationName );
41
- }
42
-
33
+ final AgentSpan span = startSpan (operationName , parent != null ? parent .context () : null );
43
34
afterStart (span );
44
35
45
- try (final AgentScope scope = activateSpan (span )) {
46
- scope .setAsyncPropagation (true );
36
+ try (final AgentScope scope = activateSpan (span , true )) {
47
37
delegate .call (new TracedSubscriber (span , subscriber , decorator ));
48
38
}
49
39
}
0 commit comments