Remove opentracing from dd-trace-api
MODIFY
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ExecutorInstrumentation.java
dd-java-agent/instrumentation/java-concurrent/src/main/java/datadog/trace/instrumentation/java/concurrent/ExecutorInstrumentation.java
@@ -237,11 +237,11 @@ public final class ExecutorInstrumentation extends Instrumenter.Configurable {
@Override
public void run() {
- final Scope scope = continuation.activate();
+ final ContextPropagator context = continuation.activate();
try {
delegatee.run();
} finally {
- scope.close();
+ context.close();
}
}
}
@@ -257,11 +257,11 @@ public final class ExecutorInstrumentation extends Instrumenter.Configurable {
@Override
public T call() throws Exception {
- final Scope scope = continuation.activate();
+ final ContextPropagator context = continuation.activate();
try {
return delegatee.call();
} finally {
- scope.close();
+ context.close();
}
}
}

MODIFY
dd-trace-api/dd-trace-api.gradle
dd-trace-api/dd-trace-api.gradle
@@ -5,6 +5,5 @@ apply from: "${rootDir}/gradle/jacoco.gradle"
description = 'dd-trace-api'
dependencies {
compile deps.slf4j
- compile deps.opentracing
testCompile deps.junit
}

MODIFY
dd-trace-api/src/main/java/datadog/trace/context/ContextPropagator.java
dd-trace-api/src/main/java/datadog/trace/context/ContextPropagator.java
package datadog.trace.context;
-import io.opentracing.Scope;
-
/** An object when can propagate a datadog trace across multiple threads. */
public interface ContextPropagator {
/**
* Prevent the trace attached to this ContextPropagator from reporting until the returned
* Continuation finishes.
+ *
+ * <p>Should be called on the parent thread.
*/
- public Continuation capture(boolean finishOnClose);
+ Continuation capture(boolean finishOnClose);
+
+ /** Close the activated context and allow any underlying spans to finish. */
+ void close();
/** Used to pass async context between workers. */
- public static interface Continuation {
+ interface Continuation {
/**
- * Activate the continuation. When the returned scope is closed, the continuation will no longer
- * prevent the trace from reporting.
+ * Activate the continuation.
+ *
+ * <p>Should be called on the child thread.
*/
- public Scope activate();
+ ContextPropagator activate();
}
}

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/scopemanager/ContinuableScope.java
dd-trace-ot/src/main/java/datadog/opentracing/scopemanager/ContinuableScope.java
@@ -86,7 +86,7 @@ public class ContinuableScope implements Scope, ContextPropagator {
}
}
- public Scope activate() {
+ public ClosingScope activate() {
if (used.compareAndSet(false, true)) {
for (final ScopeContext context : scopeManager.scopeContexts) {
if (context.inContext()) {
@@ -97,7 +97,7 @@ public class ContinuableScope implements Scope, ContextPropagator {
new ContinuableScope(scopeManager, refCount, wrapped, finishSpanOnClose));
} else {
log.debug("Reusing a continuation not allowed. Returning no-op scope.");
- return NoopScopeManager.NoopScope.INSTANCE;
+ return new ClosingScope(NoopScopeManager.NoopScope.INSTANCE);
}
}
@@ -109,17 +109,30 @@ public class ContinuableScope implements Scope, ContextPropagator {
}
}
- private class ClosingScope implements Scope {
+ private class ClosingScope implements Scope, ContextPropagator {
private final Scope wrappedScope;
private ClosingScope(final Scope wrappedScope) {
this.wrappedScope = wrappedScope;
}
+ @Override
+ public Continuation capture(boolean finishOnClose) {
+ if (wrappedScope instanceof ContextPropagator) {
+ return ((ContextPropagator) wrappedScope).capture(finishOnClose);
+ } else {
+ log.debug(
+ "{} Failed to capture. ClosingScope does not wrap a ContextPropagator: {}.",
+ this,
+ wrappedScope);
+ return null;
+ }
+ }
+
@Override
public void close() {
wrappedScope.close();
- Continuation.this.close();
+ ContinuableScope.Continuation.this.close();
}
@Override

Remove opentracing from dd-trace-api