Add default config values to the yaml config
MODIFY
dd-trace/src/main/java/com/datadoghq/trace/resolver/TracerConfig.java
dd-trace/src/main/java/com/datadoghq/trace/resolver/TracerConfig.java
package com.datadoghq.trace.resolver;
+import com.datadoghq.trace.writer.DDAgentWriter;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -12,8 +13,8 @@ import java.util.Map;
public class TracerConfig {
private String defaultServiceName;
- private WriterConfig writer;
- private SamplerConfig sampler;
+ private WriterConfig writer = new WriterConfig();
+ private SamplerConfig sampler = new SamplerConfig();
private List<DDSpanDecoratorConfig> decorators;
public String getDefaultServiceName() {
@@ -62,7 +63,7 @@ public class TracerConfig {
class SamplerConfig {
private Double rate;
- private String type;
+ private String type = "AllSampler";
private Map<String, String> skipTagsPatterns;
public String getType() {
@@ -88,9 +89,9 @@ class SamplerConfig {
class WriterConfig {
- private String host;
- private Integer port;
- private String type;
+ private String host = "localhost";
+ private Integer port = 8126;
+ private String type = DDAgentWriter.class.getSimpleName();
public void setHost(final String host) {
this.host = host;

MODIFY
dd-trace/src/test/java/com/datadoghq/trace/resolver/DDTracerFactoryTest.java
dd-trace/src/test/java/com/datadoghq/trace/resolver/DDTracerFactoryTest.java
@@ -9,6 +9,21 @@ import org.junit.Test;
public class DDTracerFactoryTest {
+ @Test
+ public void testDefaults() throws Exception {
+ final TracerConfig tracerConfig =
+ FactoryUtils.loadConfigFromResource("dd-trace-default.yaml", TracerConfig.class);
+
+ assertThat(tracerConfig.getWriter()).isNotNull();
+ assertThat(tracerConfig.getSampler()).isNotNull();
+ assertThat(tracerConfig.getDefaultServiceName()).isEqualTo("java-app-default");
+ assertThat(tracerConfig.getWriter().getHost()).isEqualTo("localhost");
+ assertThat(tracerConfig.getWriter().getPort()).isEqualTo(8126);
+ assertThat(tracerConfig.getWriter().getType()).isEqualTo(DDAgentWriter.class.getSimpleName());
+ assertThat(tracerConfig.getSampler().getType()).isEqualTo(AllSampler.class.getSimpleName());
+ assertThat(tracerConfig.getSampler().getRate()).isNull();
+ }
+
@Test
public void test() throws Exception {
TracerConfig tracerConfig =

ADD
dd-trace/src/test/resources/dd-trace-default.yaml
+defaultServiceName: java-app-default

Add default config values to the yaml config