Skip to content

Commit

Permalink
Remove service name split by tags (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Nov 20, 2019
1 parent 77941fb commit 5ad3aea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 77 deletions.
15 changes: 0 additions & 15 deletions dd-trace-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -69,7 +68,6 @@ public class Config {
public static final String HTTP_CLIENT_TAG_QUERY_STRING = "http.client.tag.query-string";
public static final String HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN = "trace.http.client.split-by-domain";
public static final String DB_CLIENT_HOST_SPLIT_BY_INSTANCE = "trace.db.client.split-by-instance";
public static final String SPLIT_BY_TAGS = "trace.split-by-tags";
public static final String PARTIAL_FLUSH_MIN_SPANS = "trace.partial.flush.min.spans";
public static final String RUNTIME_CONTEXT_FIELD_INJECTION =
"trace.runtime.context.field.injection";
Expand Down Expand Up @@ -111,7 +109,6 @@ public class Config {
private static final boolean DEFAULT_HTTP_CLIENT_TAG_QUERY_STRING = false;
private static final boolean DEFAULT_HTTP_CLIENT_SPLIT_BY_DOMAIN = false;
private static final boolean DEFAULT_DB_CLIENT_HOST_SPLIT_BY_INSTANCE = false;
private static final String DEFAULT_SPLIT_BY_TAGS = "";
private static final int DEFAULT_PARTIAL_FLUSH_MIN_SPANS = 1000;
private static final String DEFAULT_PROPAGATION_STYLE_EXTRACT = PropagationStyle.DATADOG.name();
private static final String DEFAULT_PROPAGATION_STYLE_INJECT = PropagationStyle.DATADOG.name();
Expand Down Expand Up @@ -164,7 +161,6 @@ public enum PropagationStyle {
@Getter private final boolean httpClientTagQueryString;
@Getter private final boolean httpClientSplitByDomain;
@Getter private final boolean dbClientSplitByInstance;
@Getter private final Set<String> splitByTags;
@Getter private final Integer partialFlushMinSpans;
@Getter private final boolean runtimeContextFieldInjection;
@Getter private final Set<PropagationStyle> propagationStylesToExtract;
Expand Down Expand Up @@ -243,11 +239,6 @@ public enum PropagationStyle {
getBooleanSettingFromEnvironment(
DB_CLIENT_HOST_SPLIT_BY_INSTANCE, DEFAULT_DB_CLIENT_HOST_SPLIT_BY_INSTANCE);

splitByTags =
Collections.unmodifiableSet(
new LinkedHashSet<>(
getListSettingFromEnvironment(SPLIT_BY_TAGS, DEFAULT_SPLIT_BY_TAGS)));

partialFlushMinSpans =
getIntegerSettingFromEnvironment(PARTIAL_FLUSH_MIN_SPANS, DEFAULT_PARTIAL_FLUSH_MIN_SPANS);

Expand Down Expand Up @@ -345,12 +336,6 @@ private Config(final Properties properties, final Config parent) {
getPropertyBooleanValue(
properties, DB_CLIENT_HOST_SPLIT_BY_INSTANCE, parent.dbClientSplitByInstance);

splitByTags =
Collections.unmodifiableSet(
new LinkedHashSet<>(
getPropertyListValue(
properties, SPLIT_BY_TAGS, new ArrayList<>(parent.splitByTags))));

partialFlushMinSpans =
getPropertyIntegerValue(properties, PARTIAL_FLUSH_MIN_SPANS, parent.partialFlushMinSpans);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import static datadog.trace.api.Config.SERVICE_MAPPING
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.SPLIT_BY_TAGS
import static datadog.trace.api.Config.TRACE_AGENT_PORT
import static datadog.trace.api.Config.TRACE_ENABLED
import static datadog.trace.api.Config.TRACE_REPORT_HOSTNAME
Expand Down Expand Up @@ -74,7 +73,6 @@ class ConfigTest extends DDSpecification {
config.httpClientErrorStatuses == (400..499).toSet()
config.httpClientSplitByDomain == false
config.dbClientSplitByInstance == false
config.splitByTags == [].toSet()
config.partialFlushMinSpans == 1000
config.reportHostName == false
config.runtimeContextFieldInjection == true
Expand Down Expand Up @@ -113,7 +111,6 @@ class ConfigTest extends DDSpecification {
prop.setProperty(HTTP_CLIENT_ERROR_STATUSES, "111")
prop.setProperty(HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "true")
prop.setProperty(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true")
prop.setProperty(SPLIT_BY_TAGS, "some.tag1,some.tag2,some.tag1")
prop.setProperty(PARTIAL_FLUSH_MIN_SPANS, "15")
prop.setProperty(TRACE_REPORT_HOSTNAME, "true")
prop.setProperty(RUNTIME_CONTEXT_FIELD_INJECTION, "false")
Expand Down Expand Up @@ -142,7 +139,6 @@ class ConfigTest extends DDSpecification {
config.httpClientErrorStatuses == (111..111).toSet()
config.httpClientSplitByDomain == true
config.dbClientSplitByInstance == true
config.splitByTags == ["some.tag1", "some.tag2"].toSet()
config.partialFlushMinSpans == 15
config.reportHostName == true
config.runtimeContextFieldInjection == false
Expand Down Expand Up @@ -172,7 +168,6 @@ class ConfigTest extends DDSpecification {
System.setProperty(PREFIX + HTTP_CLIENT_ERROR_STATUSES, "111")
System.setProperty(PREFIX + HTTP_CLIENT_HOST_SPLIT_BY_DOMAIN, "true")
System.setProperty(PREFIX + DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true")
System.setProperty(PREFIX + SPLIT_BY_TAGS, "some.tag3, some.tag2, some.tag1")
System.setProperty(PREFIX + PARTIAL_FLUSH_MIN_SPANS, "25")
System.setProperty(PREFIX + TRACE_REPORT_HOSTNAME, "true")
System.setProperty(PREFIX + RUNTIME_CONTEXT_FIELD_INJECTION, "false")
Expand Down Expand Up @@ -201,7 +196,6 @@ class ConfigTest extends DDSpecification {
config.httpClientErrorStatuses == (111..111).toSet()
config.httpClientSplitByDomain == true
config.dbClientSplitByInstance == true
config.splitByTags == ["some.tag3", "some.tag2", "some.tag1"].toSet()
config.partialFlushMinSpans == 25
config.reportHostName == true
config.runtimeContextFieldInjection == false
Expand Down Expand Up @@ -290,7 +284,6 @@ class ConfigTest extends DDSpecification {
config.httpClientErrorStatuses == (400..499).toSet()
config.httpClientSplitByDomain == false
config.dbClientSplitByInstance == false
config.splitByTags == [].toSet()
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG]
}
Expand Down Expand Up @@ -379,7 +372,6 @@ class ConfigTest extends DDSpecification {
config.httpClientErrorStatuses == (111..111).toSet()
config.httpClientSplitByDomain == true
config.dbClientSplitByInstance == true
config.splitByTags == [].toSet()
config.partialFlushMinSpans == 15
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
package datadog.opentracing.decorators;

import datadog.trace.api.Config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/** Create DDSpanDecorators */
public class DDDecoratorsFactory {
public static List<AbstractDecorator> createBuiltinDecorators() {

final List<AbstractDecorator> decorators =
new ArrayList<>(
Arrays.asList(
new DBStatementAsResourceName(),
new DBTypeDecorator(),
new ErrorFlag(),
new OperationDecorator(),
new PeerServiceDecorator(),
new ResourceNameDecorator(),
new ServiceNameDecorator(),
new ServiceNameDecorator("service", false),
new ServletContextDecorator(),
new SpanTypeDecorator(),
new Status404Decorator(),
new Status5XXDecorator(),
new URLAsResourceName()));

for (final String splitByTag : Config.get().getSplitByTags()) {
decorators.add(new ServiceNameDecorator(splitByTag, true));
}

return decorators;
return Arrays.asList(
new DBStatementAsResourceName(),
new DBTypeDecorator(),
new ErrorFlag(),
new OperationDecorator(),
new PeerServiceDecorator(),
new ResourceNameDecorator(),
new ServiceNameDecorator(),
new ServiceNameDecorator("service"),
new ServletContextDecorator(),
new SpanTypeDecorator(),
new Status404Decorator(),
new Status5XXDecorator(),
new URLAsResourceName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@

public class ServiceNameDecorator extends AbstractDecorator {

private final boolean setTag;

public ServiceNameDecorator() {
this(DDTags.SERVICE_NAME, false);
this(DDTags.SERVICE_NAME);
}

public ServiceNameDecorator(final String splitByTag, final boolean setTag) {
super();
this.setTag = setTag;
setMatchingTag(splitByTag);
public ServiceNameDecorator(final String tagName) {
setMatchingTag(tagName);
}

@Override
public boolean shouldSetTag(final DDSpanContext context, final String tag, final Object value) {
context.setServiceName(String.valueOf(value));
return setTag;
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package datadog.opentracing.decorators
import datadog.opentracing.DDSpanContext
import datadog.opentracing.DDTracer
import datadog.opentracing.SpanFactory
import datadog.trace.agent.test.utils.ConfigUtils
import datadog.trace.api.Config
import datadog.trace.api.DDSpanTypes
import datadog.trace.api.DDTags
import datadog.trace.common.writer.LoggingWriter
Expand All @@ -16,17 +14,7 @@ import static datadog.trace.api.Config.DEFAULT_SERVICE_NAME
import static java.util.Collections.emptyMap

class SpanDecoratorTest extends DDSpecification {
static {
ConfigUtils.updateConfig {
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)

Expand Down Expand Up @@ -77,10 +65,6 @@ class SpanDecoratorTest extends DDSpecification {
"service" | "other-service" | "other-service"
Tags.PEER_SERVICE.key | "some-service" | "new-service"
Tags.PEER_SERVICE.key | "other-service" | "other-service"
"sn.tag1" | "some-service" | "new-service"
"sn.tag1" | "other-service" | "other-service"
"sn.tag2" | "some-service" | "new-service"
"sn.tag2" | "other-service" | "other-service"

mapping = ["some-service": "new-service"]
}
Expand Down Expand Up @@ -295,12 +279,6 @@ class SpanDecoratorTest extends DDSpecification {
}

def "decorators apply to builder too"() {
when:
def span = tracer.buildSpan("decorator.test").withTag("sn.tag1", "some val").start()

then:
span.serviceName == "some val"

when:
span = tracer.buildSpan("decorator.test").withTag("servlet.context", "/my-servlet").start()

Expand Down

0 comments on commit 5ad3aea

Please sign in to comment.