Remove opentracing from dd-trace-api
This commit is contained in:
parent
4bebce2f56
commit
21180530ea
|
@ -237,11 +237,11 @@ public final class ExecutorInstrumentation extends Instrumenter.Configurable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final Scope scope = continuation.activate();
|
final ContextPropagator context = continuation.activate();
|
||||||
try {
|
try {
|
||||||
delegatee.run();
|
delegatee.run();
|
||||||
} finally {
|
} finally {
|
||||||
scope.close();
|
context.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,11 +257,11 @@ public final class ExecutorInstrumentation extends Instrumenter.Configurable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T call() throws Exception {
|
public T call() throws Exception {
|
||||||
final Scope scope = continuation.activate();
|
final ContextPropagator context = continuation.activate();
|
||||||
try {
|
try {
|
||||||
return delegatee.call();
|
return delegatee.call();
|
||||||
} finally {
|
} finally {
|
||||||
scope.close();
|
context.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,5 @@ apply from: "${rootDir}/gradle/jacoco.gradle"
|
||||||
description = 'dd-trace-api'
|
description = 'dd-trace-api'
|
||||||
dependencies {
|
dependencies {
|
||||||
compile deps.slf4j
|
compile deps.slf4j
|
||||||
compile deps.opentracing
|
|
||||||
testCompile deps.junit
|
testCompile deps.junit
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
package datadog.trace.context;
|
package datadog.trace.context;
|
||||||
|
|
||||||
import io.opentracing.Scope;
|
|
||||||
|
|
||||||
/** An object when can propagate a datadog trace across multiple threads. */
|
/** An object when can propagate a datadog trace across multiple threads. */
|
||||||
public interface ContextPropagator {
|
public interface ContextPropagator {
|
||||||
/**
|
/**
|
||||||
* Prevent the trace attached to this ContextPropagator from reporting until the returned
|
* Prevent the trace attached to this ContextPropagator from reporting until the returned
|
||||||
* Continuation finishes.
|
* 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. */
|
/** 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
|
* Activate the continuation.
|
||||||
* prevent the trace from reporting.
|
*
|
||||||
|
* <p>Should be called on the child thread.
|
||||||
*/
|
*/
|
||||||
public Scope activate();
|
ContextPropagator activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class ContinuableScope implements Scope, ContextPropagator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Scope activate() {
|
public ClosingScope activate() {
|
||||||
if (used.compareAndSet(false, true)) {
|
if (used.compareAndSet(false, true)) {
|
||||||
for (final ScopeContext context : scopeManager.scopeContexts) {
|
for (final ScopeContext context : scopeManager.scopeContexts) {
|
||||||
if (context.inContext()) {
|
if (context.inContext()) {
|
||||||
|
@ -97,7 +97,7 @@ public class ContinuableScope implements Scope, ContextPropagator {
|
||||||
new ContinuableScope(scopeManager, refCount, wrapped, finishSpanOnClose));
|
new ContinuableScope(scopeManager, refCount, wrapped, finishSpanOnClose));
|
||||||
} else {
|
} else {
|
||||||
log.debug("Reusing a continuation not allowed. Returning no-op scope.");
|
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 final Scope wrappedScope;
|
||||||
|
|
||||||
private ClosingScope(final Scope wrappedScope) {
|
private ClosingScope(final Scope wrappedScope) {
|
||||||
this.wrappedScope = 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
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
wrappedScope.close();
|
wrappedScope.close();
|
||||||
Continuation.this.close();
|
ContinuableScope.Continuation.this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue