Apply workaround to refresh configuration values during tests
MODIFY
dd-trace-api/src/main/java/datadog/trace/api/Config.java
dd-trace-api/src/main/java/datadog/trace/api/Config.java
@@ -151,7 +151,9 @@ public class Config {
@Getter private final boolean logsInjectionEnabled;
// If `true` the hostname will be detected and added to the root span's metadata
- @Getter private final boolean reportHostName;
+ // Note: this temporarily non final as a conversation is in place related to how to improve
+ // testability under different configuration scenarios.
+ @Getter private boolean reportHostName;
// Read order: System Properties -> Env Variables, [-> default value]
// Visible for testing
@@ -658,4 +660,13 @@ public class Config {
return new Config(properties, INSTANCE);
}
}
+
+ /**
+ * Note: this is a workaround as a conversation related to improve testability of services under
+ * different configuration scenarios is in progress.
+ */
+ public void refreshDetectHostnameProperty() {
+ this.reportHostName =
+ getBooleanSettingFromEnvironment(TRACE_REPORT_HOSTNAME, DEFAULT_TRACE_REPORT_HOSTNAME);
+ }
}

MODIFY
dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy
dd-trace-ot/src/test/groovy/datadog/trace/DDTracerTest.groovy
@@ -167,6 +167,7 @@ class DDTracerTest extends Specification {
def "tracer sets the host name if activated only on root span"() {
setup:
System.setProperty('dd.trace.report-hostname', 'true')
+ Config.get().refreshDetectHostnameProperty()
def tracer = new DDTracer('my_service', new ListWriter(), new AllSampler())
when:

Apply workaround to refresh configuration values during tests