Make config modifiable and still allow tag to be set.
MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
@@ -22,7 +22,7 @@ public class DDDecoratorsFactory {
new PeerServiceDecorator(),
new ResourceNameDecorator(),
new ServiceNameDecorator(),
- new ServiceNameDecorator("service"),
+ new ServiceNameDecorator("service", false),
new ServletContextDecorator(),
new SpanTypeDecorator(),
new Status404Decorator(),
@@ -30,7 +30,7 @@ public class DDDecoratorsFactory {
new URLAsResourceName()));
for (final String splitByTag : Config.get().getSplitByTags()) {
- decorators.add(new ServiceNameDecorator(splitByTag));
+ decorators.add(new ServiceNameDecorator(splitByTag, true));
}
return decorators;

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/decorators/ServiceNameDecorator.java
dd-trace-ot/src/main/java/datadog/opentracing/decorators/ServiceNameDecorator.java
@@ -5,19 +5,21 @@ import datadog.trace.api.DDTags;
public class ServiceNameDecorator extends AbstractDecorator {
+ private final boolean setTag;
+
public ServiceNameDecorator() {
- super();
- setMatchingTag(DDTags.SERVICE_NAME);
+ this(DDTags.SERVICE_NAME, false);
}
- public ServiceNameDecorator(final String splitByTag) {
+ public ServiceNameDecorator(final String splitByTag, final boolean setTag) {
super();
+ this.setTag = setTag;
setMatchingTag(splitByTag);
}
@Override
public boolean shouldSetTag(final DDSpanContext context, final String tag, final Object value) {
context.setServiceName(String.valueOf(value));
- return false;
+ return setTag;
}
}

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanBuilderTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanBuilderTest.groovy
@@ -2,6 +2,7 @@ package datadog.opentracing
import datadog.opentracing.propagation.ExtractedContext
import datadog.opentracing.propagation.TagContext
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.Config
import datadog.trace.api.DDTags
import datadog.trace.api.sampling.PrioritySampling
@@ -16,6 +17,10 @@ import static org.mockito.Mockito.mock
import static org.mockito.Mockito.when
class DDSpanBuilderTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
+
def writer = new ListWriter()
def config = Config.get()
def tracer = new DDTracer(writer)

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanSerializationTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanSerializationTest.groovy
@@ -3,6 +3,7 @@ package datadog.opentracing
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.common.collect.Maps
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.DDTags
import datadog.trace.api.sampling.PrioritySampling
import datadog.trace.common.writer.ListWriter
@@ -13,6 +14,9 @@ import org.msgpack.value.ValueType
import spock.lang.Specification
class DDSpanSerializationTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
def "serialize spans with sampling #samplingPriority"() throws Exception {
setup:

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy
@@ -2,6 +2,7 @@ package datadog.opentracing
import datadog.opentracing.propagation.ExtractedContext
import datadog.opentracing.propagation.TagContext
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.sampling.PrioritySampling
import datadog.trace.common.sampling.RateByServiceSampler
import datadog.trace.common.writer.ListWriter
@@ -14,6 +15,10 @@ import java.util.concurrent.TimeUnit
import static datadog.trace.api.Config.DEFAULT_SERVICE_NAME
class DDSpanTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
+
def writer = new ListWriter()
def tracer = new DDTracer(DEFAULT_SERVICE_NAME, writer, new RateByServiceSampler(), [:])

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/PendingTraceTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/PendingTraceTest.groovy
package datadog.opentracing
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.Config
import datadog.trace.common.writer.ListWriter
import datadog.trace.util.gc.GCUtils
@@ -14,6 +15,10 @@ import java.util.concurrent.atomic.AtomicInteger
import static datadog.trace.api.Config.PARTIAL_FLUSH_MIN_SPANS
class PendingTraceTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
+
def traceCount = new AtomicInteger()
def writer = new ListWriter() {
@Override

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/SpanFactory.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/SpanFactory.groovy
package datadog.opentracing
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.sampling.PrioritySampling
import datadog.trace.common.writer.ListWriter
class SpanFactory {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
+
static newSpanOf(long timestampMicro, String threadName = Thread.currentThread().name) {
def writer = new ListWriter()
def tracer = new DDTracer(writer)

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/TraceCorrelationTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/TraceCorrelationTest.groovy
package datadog.opentracing
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.common.writer.ListWriter
import spock.lang.Shared
import spock.lang.Specification
class TraceCorrelationTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
static final WRITER = new ListWriter()

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/TraceInterceptorTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/TraceInterceptorTest.groovy
package datadog.opentracing
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.GlobalTracer
import datadog.trace.api.interceptor.MutableSpan
import datadog.trace.api.interceptor.TraceInterceptor
@@ -9,6 +10,10 @@ import spock.lang.Specification
import java.util.concurrent.atomic.AtomicBoolean
class TraceInterceptorTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
+
def writer = new ListWriter()
def tracer = new DDTracer(writer)

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/SpanDecoratorTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/SpanDecoratorTest.groovy
@@ -23,6 +23,12 @@ class SpanDecoratorTest extends Specification {
System.setProperty("dd.$Config.SPLIT_BY_TAGS", "sn.tag1,sn.tag2")
}
}
+
+ def cleanupSpec() {
+ ConfigUtils.updateConfig {
+ System.clearProperty("dd.$Config.SPLIT_BY_TAGS")
+ }
+ }
def tracer = new DDTracer(new LoggingWriter())
def span = SpanFactory.newSpanOf(tracer)

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/URLAsResourceNameTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/URLAsResourceNameTest.groovy
@@ -3,6 +3,7 @@ package datadog.opentracing.decorators
import datadog.opentracing.DDSpanContext
import datadog.opentracing.DDTracer
import datadog.opentracing.PendingTrace
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.sampling.PrioritySampling
import datadog.trace.common.writer.ListWriter
import io.opentracing.tag.Tags
@@ -10,6 +11,10 @@ import spock.lang.Specification
import spock.lang.Subject
class URLAsResourceNameTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
+
def writer = new ListWriter()
def tracer = new DDTracer(writer)

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/resolver/DDTracerResolverTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/resolver/DDTracerResolverTest.groovy
package datadog.opentracing.resolver
import datadog.opentracing.DDTracer
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.Config
import io.opentracing.contrib.tracerresolver.TracerResolver
import spock.lang.Specification
class DDTracerResolverTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
def resolver = new DDTracerResolver()

MODIFY
dd-trace-ot/src/test/groovy/datadog/opentracing/scopemanager/ScopeManagerTest.groovy
dd-trace-ot/src/test/groovy/datadog/opentracing/scopemanager/ScopeManagerTest.groovy
@@ -3,6 +3,7 @@ package datadog.opentracing.scopemanager
import datadog.opentracing.DDSpan
import datadog.opentracing.DDSpanContext
import datadog.opentracing.DDTracer
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.common.writer.ListWriter
import datadog.trace.context.ScopeListener
import datadog.trace.util.gc.GCUtils
@@ -22,6 +23,9 @@ import java.util.concurrent.atomic.AtomicReference
import static java.util.concurrent.TimeUnit.SECONDS
class ScopeManagerTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
def latch
def writer
def tracer

MODIFY
dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy
dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy
@@ -2,6 +2,7 @@ package datadog.trace
import datadog.opentracing.DDTracer
import datadog.opentracing.propagation.HttpCodec
+import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.Config
import datadog.trace.common.sampling.AllSampler
import datadog.trace.common.sampling.RateByServiceSampler
@@ -22,6 +23,10 @@ import static datadog.trace.api.Config.SPAN_TAGS
import static datadog.trace.api.Config.WRITER_TYPE
class DDTracerTest extends Specification {
+ static {
+ ConfigUtils.makeConfigInstanceModifiable()
+ }
+
@Rule
public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties()
@Rule

Make config modifiable and still allow tag to be set.