Skip to content

Commit

Permalink
Remove propagation formats (#24)
Browse files Browse the repository at this point in the history
* Remove Haystack propagation format

* Remove B3 propagation format

* Remove header tags

* Remove origin

* Remove TagContext class

* Remove baggage items

* Remove propagation config
  • Loading branch information
trask authored Nov 22, 2019
1 parent 9f322c0 commit e6ad427
Show file tree
Hide file tree
Showing 28 changed files with 88 additions and 1,271 deletions.
3 changes: 2 additions & 1 deletion dd-trace-api/dd-trace-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ excludedClassesCoverage += [
'datadog.trace.api.DDTraceApiInfo',
'datadog.trace.api.GlobalTracer*',
'datadog.trace.api.CorrelationIdentifier',
'datadog.trace.api.DDTags'
'datadog.trace.api.DDTags',
'datadog.trace.api.Config'
]

description = 'dd-trace-api'
Expand Down
42 changes: 0 additions & 42 deletions dd-trace-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public class Config {
public static final String TRACE_METHODS = "trace.methods";
public static final String TRACE_CLASSES_EXCLUDE = "trace.classes.exclude";
public static final String TRACE_REPORT_HOSTNAME = "trace.report-hostname";
public static final String HEADER_TAGS = "trace.header.tags";
public static final String HTTP_SERVER_ERROR_STATUSES = "http.server.error.statuses";
public static final String HTTP_CLIENT_ERROR_STATUSES = "http.client.error.statuses";
public static final String HTTP_SERVER_TAG_QUERY_STRING = "http.server.tag.query-string";
Expand All @@ -70,8 +69,6 @@ public class Config {
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";
public static final String PROPAGATION_STYLE_EXTRACT = "propagation.style.extract";
public static final String PROPAGATION_STYLE_INJECT = "propagation.style.inject";

public static final String HEALTH_METRICS_ENABLED = "trace.health.metrics.enabled";
public static final String HEALTH_METRICS_STATSD_HOST = "trace.health.metrics.statsd.host";
Expand Down Expand Up @@ -109,8 +106,6 @@ public class Config {
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 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();

public static final boolean DEFAULT_METRICS_ENABLED = false;
// No default constants for metrics statsd support -- falls back to jmx fetch values
Expand All @@ -125,12 +120,6 @@ public class Config {
private static final String DEFAULT_TRACE_EXECUTORS = "";
private static final String DEFAULT_TRACE_METHODS = null;

public enum PropagationStyle {
DATADOG,
B3,
HAYSTACK
}

/** A tag intended for internal use only, hence not added to the public api DDTags class. */
private static final String INTERNAL_HOST_NAME = "_dd.hostname";

Expand All @@ -152,7 +141,6 @@ public enum PropagationStyle {
private final Map<String, String> spanTags;
private final Map<String, String> jmxTags;
@Getter private final List<String> excludedClasses;
@Getter private final Map<String, String> headerTags;
@Getter private final Set<Integer> httpServerErrorStatuses;
@Getter private final Set<Integer> httpClientErrorStatuses;
@Getter private final boolean httpServerTagQueryString;
Expand All @@ -161,8 +149,6 @@ public enum PropagationStyle {
@Getter private final boolean dbClientSplitByInstance;
@Getter private final Integer partialFlushMinSpans;
@Getter private final boolean runtimeContextFieldInjection;
@Getter private final Set<PropagationStyle> propagationStylesToExtract;
@Getter private final Set<PropagationStyle> propagationStylesToInject;

@Getter private final boolean healthMetricsEnabled;
@Getter private final String healthMetricsStatsdHost;
Expand Down Expand Up @@ -210,7 +196,6 @@ public enum PropagationStyle {
jmxTags = getMapSettingFromEnvironment(JMX_TAGS, null);

excludedClasses = getListSettingFromEnvironment(TRACE_CLASSES_EXCLUDE, null);
headerTags = getMapSettingFromEnvironment(HEADER_TAGS, null);

httpServerErrorStatuses =
getIntegerRangeSettingFromEnvironment(
Expand Down Expand Up @@ -243,19 +228,6 @@ public enum PropagationStyle {
getBooleanSettingFromEnvironment(
RUNTIME_CONTEXT_FIELD_INJECTION, DEFAULT_RUNTIME_CONTEXT_FIELD_INJECTION);

propagationStylesToExtract =
getEnumSetSettingFromEnvironment(
PROPAGATION_STYLE_EXTRACT,
DEFAULT_PROPAGATION_STYLE_EXTRACT,
PropagationStyle.class,
true);
propagationStylesToInject =
getEnumSetSettingFromEnvironment(
PROPAGATION_STYLE_INJECT,
DEFAULT_PROPAGATION_STYLE_INJECT,
PropagationStyle.class,
true);

// Writer.Builder createMonitor will use the values of the JMX fetch & agent to fill-in defaults
healthMetricsEnabled =
getBooleanSettingFromEnvironment(HEALTH_METRICS_ENABLED, DEFAULT_METRICS_ENABLED);
Expand Down Expand Up @@ -306,7 +278,6 @@ private Config(final Properties properties, final Config parent) {
jmxTags = getPropertyMapValue(properties, JMX_TAGS, parent.jmxTags);
excludedClasses =
getPropertyListValue(properties, TRACE_CLASSES_EXCLUDE, parent.excludedClasses);
headerTags = getPropertyMapValue(properties, HEADER_TAGS, parent.headerTags);

httpServerErrorStatuses =
getPropertyIntegerRangeValue(
Expand Down Expand Up @@ -339,19 +310,6 @@ private Config(final Properties properties, final Config parent) {
getPropertyBooleanValue(
properties, RUNTIME_CONTEXT_FIELD_INJECTION, parent.runtimeContextFieldInjection);

final Set<PropagationStyle> parsedPropagationStylesToExtract =
getPropertySetValue(properties, PROPAGATION_STYLE_EXTRACT, PropagationStyle.class);
propagationStylesToExtract =
parsedPropagationStylesToExtract == null
? parent.propagationStylesToExtract
: parsedPropagationStylesToExtract;
final Set<PropagationStyle> parsedPropagationStylesToInject =
getPropertySetValue(properties, PROPAGATION_STYLE_INJECT, PropagationStyle.class);
propagationStylesToInject =
parsedPropagationStylesToInject == null
? parent.propagationStylesToInject
: parsedPropagationStylesToInject;

healthMetricsEnabled =
getPropertyBooleanValue(properties, HEALTH_METRICS_ENABLED, DEFAULT_METRICS_ENABLED);
healthMetricsStatsdHost =
Expand Down
43 changes: 0 additions & 43 deletions dd-trace-api/src/test/groovy/datadog/trace/api/ConfigTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import static datadog.trace.api.Config.AGENT_UNIX_DOMAIN_SOCKET
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.HEADER_TAGS
import static datadog.trace.api.Config.HEALTH_METRICS_ENABLED
import static datadog.trace.api.Config.HEALTH_METRICS_STATSD_HOST
import static datadog.trace.api.Config.HEALTH_METRICS_STATSD_PORT
Expand All @@ -21,8 +20,6 @@ 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.PROPAGATION_STYLE_EXTRACT
import static datadog.trace.api.Config.PROPAGATION_STYLE_INJECT
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
Expand All @@ -44,9 +41,6 @@ class ConfigTest extends DDSpecification {
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"
private static final DD_HEADER_TAGS_ENV = "DD_HEADER_TAGS"
private static final DD_PROPAGATION_STYLE_EXTRACT = "DD_PROPAGATION_STYLE_EXTRACT"
private static final DD_PROPAGATION_STYLE_INJECT = "DD_PROPAGATION_STYLE_INJECT"
private static final DD_TRACE_AGENT_PORT_ENV = "DD_TRACE_AGENT_PORT"
private static final DD_AGENT_PORT_LEGACY_ENV = "DD_AGENT_PORT"
private static final DD_TRACE_REPORT_HOSTNAME = "DD_TRACE_REPORT_HOSTNAME"
Expand All @@ -65,16 +59,13 @@ class ConfigTest extends DDSpecification {
config.traceResolverEnabled == true
config.mergedSpanTags == [:]
config.mergedJmxTags == [(RUNTIME_ID_TAG): config.getRuntimeId(), (SERVICE_TAG): config.serviceName]
config.headerTags == [:]
config.httpServerErrorStatuses == (500..599).toSet()
config.httpClientErrorStatuses == (400..499).toSet()
config.httpClientSplitByDomain == false
config.dbClientSplitByInstance == false
config.partialFlushMinSpans == 1000
config.reportHostName == false
config.runtimeContextFieldInjection == true
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG]
config.healthMetricsEnabled == false
config.healthMetricsStatsdHost == null
config.healthMetricsStatsdPort == null
Expand Down Expand Up @@ -102,16 +93,13 @@ class ConfigTest extends DDSpecification {
prop.setProperty(GLOBAL_TAGS, "b:2")
prop.setProperty(SPAN_TAGS, "c:3")
prop.setProperty(JMX_TAGS, "d:4")
prop.setProperty(HEADER_TAGS, "e:5")
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")
prop.setProperty(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true")
prop.setProperty(PARTIAL_FLUSH_MIN_SPANS, "15")
prop.setProperty(TRACE_REPORT_HOSTNAME, "true")
prop.setProperty(RUNTIME_CONTEXT_FIELD_INJECTION, "false")
prop.setProperty(PROPAGATION_STYLE_EXTRACT, "Datadog, B3")
prop.setProperty(PROPAGATION_STYLE_INJECT, "B3, Datadog")
prop.setProperty(HEALTH_METRICS_ENABLED, "true")
prop.setProperty(HEALTH_METRICS_STATSD_HOST, "metrics statsd host")
prop.setProperty(HEALTH_METRICS_STATSD_PORT, "654")
Expand All @@ -129,16 +117,13 @@ class ConfigTest extends DDSpecification {
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.headerTags == [e: "5"]
config.httpServerErrorStatuses == (122..457).toSet()
config.httpClientErrorStatuses == (111..111).toSet()
config.httpClientSplitByDomain == true
config.dbClientSplitByInstance == true
config.partialFlushMinSpans == 15
config.reportHostName == true
config.runtimeContextFieldInjection == false
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.healthMetricsEnabled == true
config.healthMetricsStatsdHost == "metrics statsd host"
config.healthMetricsStatsdPort == 654
Expand All @@ -157,16 +142,13 @@ class ConfigTest extends DDSpecification {
System.setProperty(PREFIX + GLOBAL_TAGS, "b:2")
System.setProperty(PREFIX + SPAN_TAGS, "c:3")
System.setProperty(PREFIX + JMX_TAGS, "d:4")
System.setProperty(PREFIX + HEADER_TAGS, "e:5")
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")
System.setProperty(PREFIX + DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true")
System.setProperty(PREFIX + PARTIAL_FLUSH_MIN_SPANS, "25")
System.setProperty(PREFIX + TRACE_REPORT_HOSTNAME, "true")
System.setProperty(PREFIX + RUNTIME_CONTEXT_FIELD_INJECTION, "false")
System.setProperty(PREFIX + PROPAGATION_STYLE_EXTRACT, "Datadog, B3")
System.setProperty(PREFIX + PROPAGATION_STYLE_INJECT, "B3, Datadog")
System.setProperty(PREFIX + HEALTH_METRICS_ENABLED, "true")
System.setProperty(PREFIX + HEALTH_METRICS_STATSD_HOST, "metrics statsd host")
System.setProperty(PREFIX + HEALTH_METRICS_STATSD_PORT, "654")
Expand All @@ -184,16 +166,13 @@ class ConfigTest extends DDSpecification {
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.headerTags == [e: "5"]
config.httpServerErrorStatuses == (122..457).toSet()
config.httpClientErrorStatuses == (111..111).toSet()
config.httpClientSplitByDomain == true
config.dbClientSplitByInstance == true
config.partialFlushMinSpans == 25
config.reportHostName == true
config.runtimeContextFieldInjection == false
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.healthMetricsEnabled == true
config.healthMetricsStatsdHost == "metrics statsd host"
config.healthMetricsStatsdPort == 654
Expand All @@ -204,8 +183,6 @@ class ConfigTest extends DDSpecification {
environmentVariables.set(DD_SERVICE_NAME_ENV, "still something else")
environmentVariables.set(DD_TRACE_ENABLED_ENV, "false")
environmentVariables.set(DD_WRITER_TYPE_ENV, "LoggingWriter")
environmentVariables.set(DD_PROPAGATION_STYLE_EXTRACT, "B3 Datadog")
environmentVariables.set(DD_PROPAGATION_STYLE_INJECT, "Datadog B3")
environmentVariables.set(DD_TRACE_REPORT_HOSTNAME, "true")

when:
Expand All @@ -215,8 +192,6 @@ class ConfigTest extends DDSpecification {
config.serviceName == "still something else"
config.traceEnabled == false
config.writerType == "LoggingWriter"
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
config.reportHostName == true
}

Expand Down Expand Up @@ -250,14 +225,11 @@ class ConfigTest extends DDSpecification {
System.setProperty(PREFIX + TRACE_AGENT_PORT, " ")
System.setProperty(PREFIX + AGENT_PORT_LEGACY, "invalid")
System.setProperty(PREFIX + TRACE_RESOLVER_ENABLED, " ")
System.setProperty(PREFIX + HEADER_TAGS, "1")
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")
System.setProperty(PREFIX + DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "invalid")
System.setProperty(PREFIX + PROPAGATION_STYLE_EXTRACT, "some garbage")
System.setProperty(PREFIX + PROPAGATION_STYLE_INJECT, " ")

when:
def config = new Config()
Expand All @@ -270,13 +242,10 @@ class ConfigTest extends DDSpecification {
config.agentPort == 8126
config.traceResolverEnabled == true
config.mergedSpanTags == [:]
config.headerTags == [:]
config.httpServerErrorStatuses == (500..599).toSet()
config.httpClientErrorStatuses == (400..499).toSet()
config.httpClientSplitByDomain == false
config.dbClientSplitByInstance == false
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG]
}

def "sys props and env vars overrides for trace_agent_port and agent_port_legacy as expected"() {
Expand Down Expand Up @@ -334,14 +303,11 @@ class ConfigTest extends DDSpecification {
properties.setProperty(GLOBAL_TAGS, "b:2")
properties.setProperty(SPAN_TAGS, "c:3")
properties.setProperty(JMX_TAGS, "d:4")
properties.setProperty(HEADER_TAGS, "e:5")
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")
properties.setProperty(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "true")
properties.setProperty(PARTIAL_FLUSH_MIN_SPANS, "15")
properties.setProperty(PROPAGATION_STYLE_EXTRACT, "B3 Datadog")
properties.setProperty(PROPAGATION_STYLE_INJECT, "Datadog B3")

when:
def config = Config.get(properties)
Expand All @@ -356,14 +322,11 @@ class ConfigTest extends DDSpecification {
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.headerTags == [e: "5"]
config.httpServerErrorStatuses == (122..457).toSet()
config.httpClientErrorStatuses == (111..111).toSet()
config.httpClientSplitByDomain == true
config.dbClientSplitByInstance == true
config.partialFlushMinSpans == 15
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
}

def "override null properties"() {
Expand Down Expand Up @@ -466,20 +429,16 @@ class ConfigTest extends DDSpecification {
def "verify mapping configs on tracer"() {
setup:
System.setProperty(PREFIX + SPAN_TAGS, mapString)
System.setProperty(PREFIX + HEADER_TAGS, mapString)
def props = new Properties()
props.setProperty(SPAN_TAGS, mapString)
props.setProperty(HEADER_TAGS, mapString)
when:
def config = new Config()
def propConfig = Config.get(props)
then:
config.spanTags == map
config.headerTags == map
propConfig.spanTags == map
propConfig.headerTags == map
where:
mapString | map
Expand Down Expand Up @@ -545,14 +504,12 @@ class ConfigTest extends DDSpecification {
def "verify null value mapping configs on tracer"() {
setup:
environmentVariables.set(DD_SPAN_TAGS_ENV, mapString)
environmentVariables.set(DD_HEADER_TAGS_ENV, mapString)
when:
def config = new Config()
then:
config.spanTags == map
config.headerTags == map
where:
mapString | map
Expand Down
10 changes: 3 additions & 7 deletions dd-trace-ot/src/main/java/datadog/opentracing/DDSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,14 @@ public final DDSpanContext context() {
*/
@Override
public final String getBaggageItem(final String key) {
return context.getBaggageItem(key);
return null;
}

/* (non-Javadoc)
* @see io.opentracing.BaseSpan#setBaggageItem(java.lang.String, java.lang.String)
*/
@Override
public final DDSpan setBaggageItem(final String key, final String value) {
context.setBaggageItem(key, value);
return this;
}

Expand Down Expand Up @@ -277,16 +276,13 @@ public final DDSpan setSpanType(final String type) {
// Getters and JSON serialisation instructions

/**
* Meta merges baggage and tags (stringified values)
* Stringified tags
*
* @return merged context baggage and tags
* @return stringified tags
*/
@JsonGetter
public Map<String, String> getMeta() {
final Map<String, String> meta = new HashMap<>();
for (final Map.Entry<String, String> entry : context().getBaggageItems().entrySet()) {
meta.put(entry.getKey(), entry.getValue());
}
for (final Map.Entry<String, Object> entry : getTags().entrySet()) {
meta.put(entry.getKey(), String.valueOf(entry.getValue()));
}
Expand Down
Loading

0 comments on commit e6ad427

Please sign in to comment.