Rename HTTP & DB decorators + seggregate configurtions of decorators in dd-trace-decorators.yaml
MODIFY
dd-java-agent/src/main/resources/dd-trace.yaml
dd-java-agent/src/main/resources/dd-trace.yaml
@@ -19,21 +19,3 @@ sampler:
# RateSample: only a portion of spans are reported to the writer
# - Param 'rate': the portion of spans to keep
type: AllSampler
\ No newline at end of file
-
-# Decorators are used to add extra information to span
-# Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator
-decorators:
- - type: HTTP
- componentName: java-web-servlet
- - type: HTTP
- componentName: java-okhttp
- desiredServiceName: http-client
- - type: DB
- componentName: java-mongo
- desiredServiceName: mongo
- - type: DB
- componentName: java-jdbc
- desiredServiceName: jdbc
- - type: HTTP
- componentName: java-aws-sdk
- desiredServiceName: aws-client
\ No newline at end of file

MODIFY
dd-trace/src/main/java/com/datadoghq/trace/resolver/DDTracerResolver.java
dd-trace/src/main/java/com/datadoghq/trace/resolver/DDTracerResolver.java
@@ -36,6 +36,8 @@ public class DDTracerResolver extends TracerResolver {
private final static Logger logger = LoggerFactory.getLogger(DDTracerResolver.class);
public static final String TRACER_CONFIG = "dd-trace.yaml";
+ public static final String DECORATORS_CONFIG = "dd-trace-decorators.yaml";
+
private final ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
@Override
@@ -80,6 +82,12 @@ public class DDTracerResolver extends TracerResolver {
//Create tracer
tracer = new DDTracer(defaultServiceName, writer, rateSampler);
+ break; // ONLY the closest resource file is taken into account
+ }
+
+ iter = classLoader.getResources(DECORATORS_CONFIG);
+ while (iter.hasMoreElements()) {
+ TracerConfig config = objectMapper.readValue(iter.nextElement().openStream(), TracerConfig.class);
//Find decorators
if (config.getDecorators() != null) {
for (Map<String, Object> map : config.getDecorators()) {
@@ -99,7 +107,7 @@ public class DDTracerResolver extends TracerResolver {
}
}
- break;
+ break; // ONLY the closest resource file is taken into account
}
} catch (IOException e) {
logger.error("Could not load tracer configuration file. Loading default tracer.", e);

MODIFY
dd-trace/src/main/resources/dd-trace.yaml
dd-trace/src/main/resources/dd-trace.yaml
@@ -19,15 +19,3 @@ sampler:
# RateSample: only a portion of spans are reported to the writer
# - Param 'rate': the portion of spans to keep
type: AllSampler
\ No newline at end of file
-
-# Decorators are used to add extra information to span
-# Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator
-decorators:
- # This span decorator leverages HTTP tags such as the URL requested
- - type: HTTP
- componentName: http
- desiredServiceName: unnamed-java-http
- # This span decorator leverages DB tags such as the statement requested
- - type: DB
- componentName: db
- desiredServiceName: unnamed-java-db

MODIFY
dd-trace/src/test/resources/dd-trace.yaml
dd-trace/src/test/resources/dd-trace.yaml
@@ -5,9 +5,5 @@ writer:
port: 10000
sampler:
type: AllSampler
-decorators:
- - type: HTTP
- componentName: hello
- desiredServiceName: world
\ No newline at end of file

Rename HTTP & DB decorators + seggregate configurtions of decorators in dd-trace-decorators.yaml