diff --git a/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/ServerDecorator.java b/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/ServerDecorator.java index a446b03b73..a13fb9d066 100644 --- a/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/ServerDecorator.java +++ b/dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/decorator/ServerDecorator.java @@ -1,6 +1,5 @@ package datadog.trace.agent.decorator; -import datadog.trace.api.Config; import datadog.trace.instrumentation.api.AgentSpan; import io.opentracing.tag.Tags; @@ -10,7 +9,6 @@ public abstract class ServerDecorator extends BaseDecorator { public AgentSpan afterStart(final AgentSpan span) { assert span != null; span.setTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER); - span.setTag(Config.LANGUAGE_TAG_KEY, Config.LANGUAGE_TAG_VALUE); return super.afterStart(span); } } diff --git a/dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/ServerDecoratorTest.groovy b/dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/ServerDecoratorTest.groovy index f0690e0c2d..cd47ed74c3 100644 --- a/dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/ServerDecoratorTest.groovy +++ b/dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/decorator/ServerDecoratorTest.groovy @@ -1,6 +1,6 @@ package datadog.trace.agent.decorator -import datadog.trace.api.Config + import datadog.trace.api.DDTags import datadog.trace.instrumentation.api.AgentSpan import io.opentracing.tag.Tags @@ -15,7 +15,6 @@ class ServerDecoratorTest extends BaseDecoratorTest { decorator.afterStart(span) then: - 1 * span.setTag(Config.LANGUAGE_TAG_KEY, Config.LANGUAGE_TAG_VALUE) 1 * span.setTag(Tags.COMPONENT.key, "test-component") 1 * span.setTag(Tags.SPAN_KIND.key, "server") 1 * span.setTag(DDTags.SPAN_TYPE, decorator.spanType()) diff --git a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/asserts/TagsAssert.groovy b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/asserts/TagsAssert.groovy index ad87bc8309..4799593c82 100644 --- a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/asserts/TagsAssert.groovy +++ b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/asserts/TagsAssert.groovy @@ -1,8 +1,6 @@ package datadog.trace.agent.test.asserts import datadog.opentracing.DDSpan -import datadog.trace.api.Config -import datadog.trace.instrumentation.api.Tags import groovy.transform.stc.ClosureParams import groovy.transform.stc.SimpleType @@ -35,27 +33,9 @@ class TagsAssert { def defaultTags(boolean distributedRootSpan = false) { assertedTags.add("thread.name") assertedTags.add("thread.id") - assertedTags.add(Config.RUNTIME_ID_TAG) - assertedTags.add(Config.LANGUAGE_TAG_KEY) assert tags["thread.name"] != null assert tags["thread.id"] != null - - // FIXME: DQH - Too much conditional logic? Maybe create specialized methods for client & server cases - - boolean isRoot = (0G == spanParentId) - if (isRoot || distributedRootSpan) { - assert tags[Config.RUNTIME_ID_TAG] == Config.get().runtimeId - } else { - assert tags[Config.RUNTIME_ID_TAG] == null - } - - boolean isServer = (tags[Tags.SPAN_KIND] == Tags.SPAN_KIND_SERVER) - if (isRoot || distributedRootSpan || isServer) { - assert tags[Config.LANGUAGE_TAG_KEY] == Config.LANGUAGE_TAG_VALUE - } else { - assert tags[Config.LANGUAGE_TAG_KEY] == null - } } def errorTags(Class errorType) { diff --git a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/utils/ConfigUtils.groovy b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/utils/ConfigUtils.groovy index c1e31efa69..fa66edcc35 100644 --- a/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/utils/ConfigUtils.groovy +++ b/dd-java-agent/testing/src/main/groovy/datadog/trace/agent/test/utils/ConfigUtils.groovy @@ -9,7 +9,6 @@ import java.util.concurrent.Callable class ConfigUtils { static final CONFIG_INSTANCE_FIELD = Config.getDeclaredField("INSTANCE") - static final RUNTIME_ID_FIELD = Config.getDeclaredField("runtimeId") @SneakyThrows synchronized static Object withConfigOverride(final String name, final String value, final Callable r) { @@ -52,16 +51,7 @@ class ConfigUtils { assert Modifier.isVolatile(CONFIG_INSTANCE_FIELD.getModifiers()) assert !Modifier.isFinal(CONFIG_INSTANCE_FIELD.getModifiers()) - assert Modifier.isPublic(RUNTIME_ID_FIELD.getModifiers()) - assert !Modifier.isStatic(RUNTIME_ID_FIELD.getModifiers()) - assert Modifier.isVolatile(RUNTIME_ID_FIELD.getModifiers()) - assert !Modifier.isFinal(RUNTIME_ID_FIELD.getModifiers()) - - def previousConfig = CONFIG_INSTANCE_FIELD.get(null) def newConfig = new Config() CONFIG_INSTANCE_FIELD.set(null, newConfig) - if (previousConfig != null) { - RUNTIME_ID_FIELD.set(newConfig, RUNTIME_ID_FIELD.get(previousConfig)) - } } } diff --git a/dd-trace-api/src/main/java/datadog/trace/api/Config.java b/dd-trace-api/src/main/java/datadog/trace/api/Config.java index 98d34e731a..c825c75059 100644 --- a/dd-trace-api/src/main/java/datadog/trace/api/Config.java +++ b/dd-trace-api/src/main/java/datadog/trace/api/Config.java @@ -14,7 +14,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.SortedSet; -import java.util.UUID; import java.util.regex.Pattern; import lombok.Getter; import lombok.ToString; @@ -43,9 +42,6 @@ public class Config { public static final String INTEGRATIONS_ENABLED = "integrations.enabled"; public static final String WRITER_TYPE = "writer.type"; public static final String TRACE_RESOLVER_ENABLED = "trace.resolver.enabled"; - public static final String GLOBAL_TAGS = "trace.global.tags"; - public static final String SPAN_TAGS = "trace.span.tags"; - public static final String JMX_TAGS = "trace.jmx.tags"; public static final String TRACE_ANNOTATIONS = "trace.annotations"; public static final String TRACE_EXECUTORS_ALL = "trace.executors.all"; public static final String TRACE_EXECUTORS = "trace.executors"; @@ -63,12 +59,6 @@ public class Config { public static final String LOGS_INJECTION_ENABLED = "logs.injection"; - public static final String SERVICE_TAG = "service"; - @Deprecated public static final String SERVICE = SERVICE_TAG; // To be removed in 0.34.0 - public static final String RUNTIME_ID_TAG = "runtime-id"; - public static final String LANGUAGE_TAG_KEY = "language"; - public static final String LANGUAGE_TAG_VALUE = "jvm"; - public static final String DEFAULT_SERVICE_NAME = "unnamed-java-app"; private static final boolean DEFAULT_TRACE_ENABLED = true; @@ -98,20 +88,11 @@ public class Config { private static final String DEFAULT_TRACE_EXECUTORS = ""; private static final String DEFAULT_TRACE_METHODS = null; - /** - * this is a random UUID that gets generated on JVM start up and is attached to every root span - * and every JMX metric that is sent out. - */ - @Getter private final String runtimeId; - @Getter private final String serviceName; @Getter private final boolean traceEnabled; @Getter private final boolean integrationsEnabled; @Getter private final String writerType; @Getter private final boolean traceResolverEnabled; - private final Map globalTags; - private final Map spanTags; - private final Map jmxTags; @Getter private final List excludedClasses; @Getter private final Set httpServerErrorStatuses; @Getter private final Set httpClientErrorStatuses; @@ -139,8 +120,6 @@ public class Config { Config() { propertiesFromConfigFile = loadConfigurationFile(); - runtimeId = UUID.randomUUID().toString(); - serviceName = getSettingFromEnvironment(SERVICE_NAME, DEFAULT_SERVICE_NAME); traceEnabled = getBooleanSettingFromEnvironment(TRACE_ENABLED, DEFAULT_TRACE_ENABLED); @@ -150,10 +129,6 @@ public class Config { traceResolverEnabled = getBooleanSettingFromEnvironment(TRACE_RESOLVER_ENABLED, DEFAULT_TRACE_RESOLVER_ENABLED); - globalTags = getMapSettingFromEnvironment(GLOBAL_TAGS, null); - spanTags = getMapSettingFromEnvironment(SPAN_TAGS, null); - jmxTags = getMapSettingFromEnvironment(JMX_TAGS, null); - excludedClasses = getListSettingFromEnvironment(TRACE_CLASSES_EXCLUDE, null); httpServerErrorStatuses = @@ -204,7 +179,6 @@ public class Config { // Read order: Properties -> Parent private Config(final Properties properties, final Config parent) { - runtimeId = parent.runtimeId; serviceName = properties.getProperty(SERVICE_NAME, parent.serviceName); @@ -215,9 +189,6 @@ public class Config { traceResolverEnabled = getPropertyBooleanValue(properties, TRACE_RESOLVER_ENABLED, parent.traceResolverEnabled); - globalTags = getPropertyMapValue(properties, GLOBAL_TAGS, parent.globalTags); - spanTags = getPropertyMapValue(properties, SPAN_TAGS, parent.spanTags); - jmxTags = getPropertyMapValue(properties, JMX_TAGS, parent.jmxTags); excludedClasses = getPropertyListValue(properties, TRACE_CLASSES_EXCLUDE, parent.excludedClasses); @@ -266,53 +237,6 @@ public class Config { log.debug("New instance: {}", this); } - /** @return A map of tags to be applied only to the local application root span. */ - public Map getLocalRootSpanTags() { - final Map runtimeTags = getRuntimeTags(); - final Map result = new HashMap<>(runtimeTags); - result.put(LANGUAGE_TAG_KEY, LANGUAGE_TAG_VALUE); - - return Collections.unmodifiableMap(result); - } - - public Map getMergedSpanTags() { - // DO not include runtimeId into span tags: we only want that added to the root span - final Map result = newHashMap(globalTags.size() + spanTags.size()); - result.putAll(globalTags); - result.putAll(spanTags); - return Collections.unmodifiableMap(result); - } - - public Map getMergedJmxTags() { - final Map runtimeTags = getRuntimeTags(); - final Map result = - newHashMap( - globalTags.size() + jmxTags.size() + runtimeTags.size() + 1 /* for serviceName */); - result.putAll(globalTags); - result.putAll(jmxTags); - result.putAll(runtimeTags); - // service name set here instead of getRuntimeTags because apm already manages the service tag - // and may chose to override it. - // Additionally, infra/JMX metrics require `service` rather than APM's `service.name` tag - result.put(SERVICE_TAG, serviceName); - return Collections.unmodifiableMap(result); - } - - /** - * Return a map of tags required by the datadog backend to link runtime metrics (i.e. jmx) and - * traces. - * - *

These tags must be applied to every runtime metrics and placed on the root span of every - * trace. - * - * @return A map of tag-name -> tag-value - */ - private Map getRuntimeTags() { - final Map result = newHashMap(2); - result.put(RUNTIME_ID_TAG, runtimeId); - return Collections.unmodifiableMap(result); - } - public boolean isIntegrationEnabled( final SortedSet integrationNames, final boolean defaultEnabled) { return integrationEnabled(integrationNames, defaultEnabled); @@ -377,13 +301,6 @@ public class Config { return defaultValue; } - /** @deprecated This method should only be used internally. Use the explicit getter instead. */ - private static Map getMapSettingFromEnvironment( - final String name, final String defaultValue) { - return parseMap( - getSettingFromEnvironment(name, defaultValue), propertyNameToSystemPropertyName(name)); - } - /** * Calls {@link #getSettingFromEnvironment(String, String)} and converts the result to a list by * splitting on `,`. diff --git a/dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy b/dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy index ce115115ac..706f3195f4 100644 --- a/dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy +++ b/dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy @@ -7,18 +7,13 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties import static datadog.trace.api.Config.CONFIGURATION_FILE import static datadog.trace.api.Config.DB_CLIENT_HOST_SPLIT_BY_INSTANCE -import static datadog.trace.api.Config.GLOBAL_TAGS import static datadog.trace.api.Config.HTTP_CLIENT_ERROR_STATUSES import static datadog.trace.api.Config.HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN import static datadog.trace.api.Config.HTTP_SERVER_ERROR_STATUSES -import static datadog.trace.api.Config.JMX_TAGS import static datadog.trace.api.Config.PARTIAL_FLUSH_MIN_SPANS import static datadog.trace.api.Config.PREFIX import static datadog.trace.api.Config.RUNTIME_CONTEXT_FIELD_INJECTION -import static datadog.trace.api.Config.RUNTIME_ID_TAG import static datadog.trace.api.Config.SERVICE_NAME -import static datadog.trace.api.Config.SERVICE_TAG -import static datadog.trace.api.Config.SPAN_TAGS import static datadog.trace.api.Config.TRACE_ENABLED import static datadog.trace.api.Config.TRACE_RESOLVER_ENABLED import static datadog.trace.api.Config.WRITER_TYPE @@ -32,7 +27,6 @@ class ConfigTest extends DDSpecification { private static final DD_SERVICE_NAME_ENV = "DD_SERVICE_NAME" private static final DD_TRACE_ENABLED_ENV = "DD_TRACE_ENABLED" private static final DD_WRITER_TYPE_ENV = "DD_WRITER_TYPE" - private static final DD_SPAN_TAGS_ENV = "DD_SPAN_TAGS" def "verify defaults"() { when: @@ -43,8 +37,6 @@ class ConfigTest extends DDSpecification { config.traceEnabled == true config.writerType == "LoggingWriter" config.traceResolverEnabled == true - config.mergedSpanTags == [:] - config.mergedJmxTags == [(RUNTIME_ID_TAG): config.getRuntimeId(), (SERVICE_TAG): config.serviceName] config.httpServerErrorStatuses == (500..599).toSet() config.httpClientErrorStatuses == (400..499).toSet() config.httpClientSplitByDomain == false @@ -68,9 +60,6 @@ class ConfigTest extends DDSpecification { prop.setProperty(TRACE_ENABLED, "false") prop.setProperty(WRITER_TYPE, "LoggingWriter") prop.setProperty(TRACE_RESOLVER_ENABLED, "false") - prop.setProperty(GLOBAL_TAGS, "b:2") - prop.setProperty(SPAN_TAGS, "c:3") - prop.setProperty(JMX_TAGS, "d:4") prop.setProperty(HTTP_SERVER_ERROR_STATUSES, "123-456,457,124-125,122") prop.setProperty(HTTP_CLIENT_ERROR_STATUSES, "111") prop.setProperty(HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "true") @@ -86,8 +75,6 @@ class ConfigTest extends DDSpecification { config.traceEnabled == false config.writerType == "LoggingWriter" config.traceResolverEnabled == false - config.mergedSpanTags == [b: "2", c: "3"] - config.mergedJmxTags == [b: "2", d: "4", (RUNTIME_ID_TAG): config.getRuntimeId(), (SERVICE_TAG): config.serviceName] config.httpServerErrorStatuses == (122..457).toSet() config.httpClientErrorStatuses == (111..111).toSet() config.httpClientSplitByDomain == true @@ -102,9 +89,6 @@ class ConfigTest extends DDSpecification { System.setProperty(PREFIX + TRACE_ENABLED, "false") System.setProperty(PREFIX + WRITER_TYPE, "LoggingWriter") System.setProperty(PREFIX + TRACE_RESOLVER_ENABLED, "false") - System.setProperty(PREFIX + GLOBAL_TAGS, "b:2") - System.setProperty(PREFIX + SPAN_TAGS, "c:3") - System.setProperty(PREFIX + JMX_TAGS, "d:4") System.setProperty(PREFIX + HTTP_SERVER_ERROR_STATUSES, "123-456,457,124-125,122") System.setProperty(PREFIX + HTTP_CLIENT_ERROR_STATUSES, "111") System.setProperty(PREFIX + HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "true") @@ -120,8 +104,6 @@ class ConfigTest extends DDSpecification { config.traceEnabled == false config.writerType == "LoggingWriter" config.traceResolverEnabled == false - config.mergedSpanTags == [b: "2", c: "3"] - config.mergedJmxTags == [b: "2", d: "4", (RUNTIME_ID_TAG): config.getRuntimeId(), (SERVICE_TAG): config.serviceName] config.httpServerErrorStatuses == (122..457).toSet() config.httpClientErrorStatuses == (111..111).toSet() config.httpClientSplitByDomain == true @@ -167,7 +149,6 @@ class ConfigTest extends DDSpecification { System.setProperty(PREFIX + TRACE_ENABLED, " ") System.setProperty(PREFIX + WRITER_TYPE, " ") System.setProperty(PREFIX + TRACE_RESOLVER_ENABLED, " ") - System.setProperty(PREFIX + SPAN_TAGS, "invalid") System.setProperty(PREFIX + HTTP_SERVER_ERROR_STATUSES, "1111") System.setProperty(PREFIX + HTTP_CLIENT_ERROR_STATUSES, "1:1") System.setProperty(PREFIX + HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "invalid") @@ -181,7 +162,6 @@ class ConfigTest extends DDSpecification { config.traceEnabled == true config.writerType == " " config.traceResolverEnabled == true - config.mergedSpanTags == [:] config.httpServerErrorStatuses == (500..599).toSet() config.httpClientErrorStatuses == (400..499).toSet() config.httpClientSplitByDomain == false @@ -195,9 +175,6 @@ class ConfigTest extends DDSpecification { properties.setProperty(TRACE_ENABLED, "false") properties.setProperty(WRITER_TYPE, "LoggingWriter") properties.setProperty(TRACE_RESOLVER_ENABLED, "false") - properties.setProperty(GLOBAL_TAGS, "b:2") - properties.setProperty(SPAN_TAGS, "c:3") - properties.setProperty(JMX_TAGS, "d:4") properties.setProperty(HTTP_SERVER_ERROR_STATUSES, "123-456,457,124-125,122") properties.setProperty(HTTP_CLIENT_ERROR_STATUSES, "111") properties.setProperty(HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "true") @@ -212,8 +189,6 @@ class ConfigTest extends DDSpecification { config.traceEnabled == false config.writerType == "LoggingWriter" config.traceResolverEnabled == false - config.mergedSpanTags == [b: "2", c: "3"] - config.mergedJmxTags == [b: "2", d: "4", (RUNTIME_ID_TAG): config.getRuntimeId(), (SERVICE_TAG): config.serviceName] config.httpServerErrorStatuses == (122..457).toSet() config.httpClientErrorStatuses == (111..111).toSet() config.httpClientSplitByDomain == true @@ -318,42 +293,6 @@ class ConfigTest extends DDSpecification { defaultValue = 10.0 } - def "verify mapping configs on tracer"() { - setup: - System.setProperty(PREFIX + SPAN_TAGS, mapString) - def props = new Properties() - props.setProperty(SPAN_TAGS, mapString) - - when: - def config = new Config() - def propConfig = Config.get(props) - - then: - config.spanTags == map - propConfig.spanTags == map - - where: - mapString | map - "a:1, a:2, a:3" | [a: "3"] - "a:b,c:d,e:" | [a: "b", c: "d"] - // More different string variants: - "a:" | [:] - "a:a;" | [a: "a;"] - "a:1, a:2, a:3" | [a: "3"] - "a:b,c:d,e:" | [a: "b", c: "d"] - "key 1!:va|ue_1," | ["key 1!": "va|ue_1"] - " key1 :value1 ,\t key2: value2" | [key1: "value1", key2: "value2"] - // Invalid strings: - "" | [:] - "1" | [:] - "a" | [:] - "a,1" | [:] - "in:val:id" | [:] - "a:b:c:d" | [:] - "a:b,c,d" | [:] - "!a" | [:] - } - def "verify integer range configs on tracer"() { setup: System.setProperty(PREFIX + HTTP_SERVER_ERROR_STATUSES, value) @@ -393,33 +332,6 @@ class ConfigTest extends DDSpecification { " 400 - 403 , 405 " | [400, 401, 402, 403, 405] } - def "verify null value mapping configs on tracer"() { - setup: - environmentVariables.set(DD_SPAN_TAGS_ENV, mapString) - - when: - def config = new Config() - - then: - config.spanTags == map - - where: - mapString | map - null | [:] - "" | [:] - } - - def "verify hostname not added to root span tags by default"() { - setup: - Properties properties = new Properties() - - when: - def config = Config.get(properties) - - then: - !config.localRootSpanTags.containsKey('_dd.hostname') - } - def "verify fallback to properties file"() { setup: System.setProperty(PREFIX + CONFIGURATION_FILE, "src/test/resources/dd-java-tracer.properties") diff --git a/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java b/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java index 90b407864f..84f8971502 100644 --- a/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java +++ b/dd-trace-ot/src/main/java/datadog/opentracing/DDTracer.java @@ -23,7 +23,6 @@ import java.lang.ref.WeakReference; import java.math.BigInteger; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,11 +47,6 @@ public class DDTracer implements io.opentracing.Tracer, Closeable, datadog.trace /** Scope manager is in charge of managing the scopes from which spans are created */ final ContextualScopeManager scopeManager = new ContextualScopeManager(); - /** A set of tags that are added only to the application's root span */ - private final Map localRootSpanTags; - /** A set of tags that are added to every span */ - private final Map defaultSpanTags; - /** number of spans in a pending trace before they get flushed */ @Getter private final int partialFlushMinSpans; @@ -86,84 +80,28 @@ public class DDTracer implements io.opentracing.Tracer, Closeable, datadog.trace this(config.getServiceName(), config); } - // This constructor is already used in the wild, so we have to keep it inside this API for now. - public DDTracer(final String serviceName, final Writer writer) { - this(serviceName, writer, Config.get().getLocalRootSpanTags()); - } - private DDTracer(final String serviceName, final Config config) { - this( - serviceName, - Writer.Builder.forConfig(config), - config.getLocalRootSpanTags(), - config.getMergedSpanTags(), - config.getPartialFlushMinSpans()); + this(serviceName, Writer.Builder.forConfig(config), config.getPartialFlushMinSpans()); log.debug("Using config: {}", config); } - /** Visible for testing */ - DDTracer(final String serviceName, final Writer writer, final Map runtimeTags) { - this(serviceName, writer, runtimeTags, Collections.emptyMap(), 0); - } - public DDTracer(final Writer writer) { this(Config.get(), writer); } public DDTracer(final Config config, final Writer writer) { - this( - config.getServiceName(), - writer, - config.getLocalRootSpanTags(), - config.getMergedSpanTags(), - config.getPartialFlushMinSpans()); + this(config.getServiceName(), writer, config.getPartialFlushMinSpans()); } - /** @deprecated Use {@link #DDTracer(String, Writer, Map, Map, int)} instead. */ - @Deprecated - public DDTracer( - final String serviceName, - final Writer writer, - final String runtimeId, - final Map localRootSpanTags, - final Map defaultSpanTags) { - this( - serviceName, - writer, - customRuntimeTags(runtimeId, localRootSpanTags), - defaultSpanTags, - Config.get().getPartialFlushMinSpans()); + public DDTracer(final String serviceName, final Writer writer) { + this(serviceName, writer, Config.get().getPartialFlushMinSpans()); } - /** @deprecated Use {@link #DDTracer(String, Writer, Map, Map,int)} instead. */ - @Deprecated - public DDTracer( - final String serviceName, - final Writer writer, - final Map localRootSpanTags, - final Map defaultSpanTags) { - this( - serviceName, - writer, - localRootSpanTags, - defaultSpanTags, - Config.get().getPartialFlushMinSpans()); - } - - public DDTracer( - final String serviceName, - final Writer writer, - final Map localRootSpanTags, - final Map defaultSpanTags, - final int partialFlushMinSpans) { - assert localRootSpanTags != null; - assert defaultSpanTags != null; + public DDTracer(final String serviceName, final Writer writer, final int partialFlushMinSpans) { this.serviceName = serviceName; this.writer = writer; this.writer.start(); - this.localRootSpanTags = localRootSpanTags; - this.defaultSpanTags = defaultSpanTags; this.partialFlushMinSpans = partialFlushMinSpans; shutdownCallback = new ShutdownHook(this); @@ -326,19 +264,9 @@ public class DDTracer implements io.opentracing.Tracer, Closeable, datadog.trace + serviceName + ", writer=" + writer - + ", defaultSpanTags=" - + defaultSpanTags + '}'; } - @Deprecated - private static Map customRuntimeTags( - final String runtimeId, final Map applicationRootSpanTags) { - final Map runtimeTags = new HashMap<>(applicationRootSpanTags); - runtimeTags.put(Config.RUNTIME_ID_TAG, runtimeId); - return Collections.unmodifiableMap(runtimeTags); - } - /** Spans are built using this builder */ public class DDSpanBuilder implements SpanBuilder { private final ScopeManager scopeManager; @@ -347,7 +275,7 @@ public class DDTracer implements io.opentracing.Tracer, Closeable, datadog.trace private final String operationName; // Builder attributes - private final Map tags = new HashMap(defaultSpanTags); + private final Map tags = new HashMap<>(); private long timestampMicro; private SpanContext parent; private String serviceName; @@ -536,8 +464,6 @@ public class DDTracer implements io.opentracing.Tracer, Closeable, datadog.trace parentSpanId = BigInteger.ZERO; } - tags.putAll(localRootSpanTags); - parentTrace = new PendingTrace(DDTracer.this, traceId); } diff --git a/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanBuilderTest.groovy b/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanBuilderTest.groovy index 515d472708..4b0e487698 100644 --- a/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanBuilderTest.groovy +++ b/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanBuilderTest.groovy @@ -53,10 +53,8 @@ class DDSpanBuilderTest extends DDSpecification { then: span.getTags() == [ - (DDTags.THREAD_NAME) : Thread.currentThread().getName(), - (DDTags.THREAD_ID) : Thread.currentThread().getId(), - (Config.RUNTIME_ID_TAG) : config.getRuntimeId(), - (Config.LANGUAGE_TAG_KEY): Config.LANGUAGE_TAG_VALUE, + (DDTags.THREAD_NAME): Thread.currentThread().getName(), + (DDTags.THREAD_ID) : Thread.currentThread().getId() ] when: @@ -400,31 +398,4 @@ class DDSpanBuilderTest extends DDSpecification { new ExtractedContext(1G, 2G) | _ new ExtractedContext(3G, 4G) | _ } - - def "global span tags populated on each span"() { - setup: - System.setProperty("dd.trace.span.tags", tagString) - def config = new Config() - tracer = new DDTracer(config, writer) - def span = tracer.buildSpan("op name").withServiceName("foo").start() - - expect: - span.tags == tags + [ - (DDTags.THREAD_NAME) : Thread.currentThread().getName(), - (DDTags.THREAD_ID) : Thread.currentThread().getId(), - (Config.RUNTIME_ID_TAG) : config.getRuntimeId(), - (Config.LANGUAGE_TAG_KEY): Config.LANGUAGE_TAG_VALUE, - ] - - cleanup: - System.clearProperty("dd.trace.span.tags") - - where: - tagString | tags - "" | [:] - "in:val:id" | [:] - "a:x" | [a: "x"] - "a:a,a:b,a:c" | [a: "c"] - "a:1,b-c:d" | [a: "1", "b-c": "d"] - } } diff --git a/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy b/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy index 1c3a2cb1e7..85238408ab 100644 --- a/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy +++ b/dd-trace-ot/src/test/groovy/datadog/opentracing/DDSpanTest.groovy @@ -12,7 +12,7 @@ import static datadog.trace.api.Config.DEFAULT_SERVICE_NAME class DDSpanTest extends DDSpecification { def writer = new ListWriter() - def tracer = new DDTracer(DEFAULT_SERVICE_NAME, writer, [:]) + def tracer = new DDTracer(DEFAULT_SERVICE_NAME, writer) def "getters and setters"() { setup: diff --git a/dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/SpanDecoratorTest.groovy b/dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/SpanDecoratorTest.groovy index f2bec02ff5..949c4af33d 100644 --- a/dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/SpanDecoratorTest.groovy +++ b/dd-trace-ot/src/test/groovy/datadog/opentracing/decorators/SpanDecoratorTest.groovy @@ -11,7 +11,6 @@ import io.opentracing.tag.StringTag import io.opentracing.tag.Tags import static datadog.trace.api.Config.DEFAULT_SERVICE_NAME -import static java.util.Collections.emptyMap class SpanDecoratorTest extends DDSpecification { @@ -42,10 +41,7 @@ class SpanDecoratorTest extends DDSpecification { setup: tracer = new DDTracer( "wrong-service", - new LoggingWriter(), - "some-runtime-id", - emptyMap(), - emptyMap() + new LoggingWriter() ) when: @@ -86,10 +82,7 @@ class SpanDecoratorTest extends DDSpecification { setup: tracer = new DDTracer( serviceName, - new LoggingWriter(), - "some-runtime-id", - emptyMap(), - emptyMap() + new LoggingWriter() ) when: diff --git a/dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy b/dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy index 423921e5ef..eb29867222 100644 --- a/dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy +++ b/dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy @@ -12,7 +12,6 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties import static datadog.trace.api.Config.DEFAULT_SERVICE_NAME import static datadog.trace.api.Config.PREFIX -import static datadog.trace.api.Config.SPAN_TAGS import static datadog.trace.api.Config.WRITER_TYPE class DDTracerTest extends DDSpecification { @@ -56,23 +55,6 @@ class DDTracerTest extends DDSpecification { tracer.writer instanceof LoggingWriter } - def "verify mapping configs on tracer"() { - setup: - System.setProperty(PREFIX + SPAN_TAGS, mapString) - - when: - def config = new Config() - def tracer = new DDTracer(config) - - then: - tracer.defaultSpanTags == map - - where: - mapString | map - "a:1, a:2, a:3" | [a: "3"] - "a:b,c:d,e:" | [a: "b", c: "d"] - } - def "verify writer constructor"() { setup: def writer = new ListWriter() @@ -83,22 +65,5 @@ class DDTracerTest extends DDSpecification { then: tracer.serviceName == DEFAULT_SERVICE_NAME tracer.writer == writer - tracer.localRootSpanTags[Config.RUNTIME_ID_TAG].size() > 0 // not null or empty - tracer.localRootSpanTags[Config.LANGUAGE_TAG_KEY] == Config.LANGUAGE_TAG_VALUE - } - - def "root tags are applied only to root spans"() { - setup: - def tracer = new DDTracer('my_service', new ListWriter(), '', ['only_root': 'value'], [:]) - def root = tracer.buildSpan('my_root').start() - def child = tracer.buildSpan('my_child').asChildOf(root).start() - - expect: - root.context().tags.containsKey('only_root') - !child.context().tags.containsKey('only_root') - - cleanup: - child.finish() - root.finish() } } diff --git a/utils/test-utils/src/main/groovy/datadog/trace/util/test/DDSpecification.groovy b/utils/test-utils/src/main/groovy/datadog/trace/util/test/DDSpecification.groovy index 0d50b5a89c..131a324915 100644 --- a/utils/test-utils/src/main/groovy/datadog/trace/util/test/DDSpecification.groovy +++ b/utils/test-utils/src/main/groovy/datadog/trace/util/test/DDSpecification.groovy @@ -42,12 +42,6 @@ abstract class DDSpecification extends Specification { .field(named("INSTANCE")) .transform(Transformer.ForField.withModifiers(PUBLIC, STATIC, VOLATILE)) } - // Making runtimeId modifiable so that it can be preserved when resetting config in tests - .transform { builder, typeDescription, classLoader, module -> - builder - .field(named("runtimeId")) - .transform(Transformer.ForField.withModifiers(PUBLIC, VOLATILE)) - } .installOn(instrumentation) isConfigInstanceModifiable = true }