Additional continuable-scope tests
MODIFY
dd-java-agent/instrumentation/slf4j-mdc/src/main/java/datadog/trace/instrumentation/slf4j/mdc/MDCInjectionInstrumentation.java
dd-java-agent/instrumentation/slf4j-mdc/src/main/java/datadog/trace/instrumentation/slf4j/mdc/MDCInjectionInstrumentation.java
@@ -102,7 +102,7 @@ public class MDCInjectionInstrumentation extends Instrumenter.Default {
}
@Override
- public void afterScopeClose() {
+ public void afterScopeClosed() {
try {
removeMethod.invoke(null, CorrelationIdentifier.getTraceIdKey());
removeMethod.invoke(null, CorrelationIdentifier.getSpanIdKey());

MODIFY
dd-trace-api/src/main/java/datadog/trace/context/ScopeListener.java
dd-trace-api/src/main/java/datadog/trace/context/ScopeListener.java
@@ -11,5 +11,5 @@ public interface ScopeListener {
void afterScopeActivated();
/** Called just after a scope is closed. */
- void afterScopeClose();
+ void afterScopeClosed();
}

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/scopemanager/ContinuableScope.java
dd-trace-ot/src/main/java/datadog/opentracing/scopemanager/ContinuableScope.java
@@ -67,7 +67,7 @@ public class ContinuableScope implements Scope, TraceScope {
}
for (final ScopeListener listener : scopeManager.scopeListeners) {
- listener.afterScopeClose();
+ listener.afterScopeClosed();
}
if (scopeManager.tlsScope.get() == this) {

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/scopemanager/SimpleScope.java
dd-trace-ot/src/main/java/datadog/opentracing/scopemanager/SimpleScope.java
@@ -31,7 +31,7 @@ public class SimpleScope implements Scope {
spanUnderScope.finish();
}
for (final ScopeListener listener : scopeManager.scopeListeners) {
- listener.afterScopeClose();
+ listener.afterScopeClosed();
}
if (scopeManager.tlsScope.get() == this) {

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/scopemanager/ScopeManagerTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/scopemanager/ScopeManagerTest.groovy
@@ -421,7 +421,7 @@ class ScopeManagerTest extends Specification {
}
@Override
- void afterScopeClose() {
+ void afterScopeClosed() {
closedCount.incrementAndGet()
}
})
@@ -453,6 +453,35 @@ class ScopeManagerTest extends Specification {
then:
activatedCount.get() == 3
closedCount.get() == 2
+
+ when:
+ Scope continuableScope = tracer.buildSpan("foo").startActive(true)
+
+ then:
+ continuableScope instanceof ContinuableScope
+ activatedCount.get() == 4
+
+ when:
+ Scope childContinuableScope = tracer.buildSpan("child").startActive(true)
+
+ then:
+ childContinuableScope instanceof ContinuableScope
+ activatedCount.get() == 5
+ closedCount.get() == 2
+
+ when:
+ childContinuableScope.close()
+
+ then:
+ activatedCount.get() == 6
+ closedCount.get() == 3
+
+ when:
+ continuableScope.close()
+
+ then:
+ activatedCount.get() == 6
+ closedCount.get() == 4
}
boolean spanFinished(Span span) {

Additional continuable-scope tests