Move default decorators to code
ADD
dd-java-agent/src/main/resources/dd-trace-decorators-default.yaml
+# Decorators are used to add extra information to span.
+# To modify, copy the file to dd-trace-decorators.yaml and make desired changes.
+# Could be DBServiceDecorator or HTTPServiceDecorator, etc.
+decorators:
+ - type: HTTPComponent
+ matchingTag: component
+ matchingValue: okhttp
+ - type: HTTPComponent
+ matchingTag: component
+ matchingValue: java-aws-sdk
+ - type: ErrorFlag
+ - type: DBTypeDecorator
+ - type: DBStatementAsResourceName
+ - type: OperationDecorator
+ - type: Status404Decorator
+ - type: URLAsResourceName

MODIFY
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java
@@ -68,12 +68,38 @@ public class DDDecoratorsFactory {
}
public static List<AbstractDecorator> createFromResources() {
- List<AbstractDecorator> result = new ArrayList<>();
+ final List<AbstractDecorator> result;
final DecoratorsConfig config =
ConfigUtils.loadConfigFromResource(CONFIG_PATH, DecoratorsConfig.class);
- if (config != null) {
+ if (config == null) {
+ result = createBuiltinDecorators();
+ } else {
result = DDDecoratorsFactory.create(config.getDecorators());
}
return result;
}
+
+ private static List<AbstractDecorator> createBuiltinDecorators() {
+ List<AbstractDecorator> builtin = new ArrayList<AbstractDecorator>(8);
+ {
+ final HTTPComponent httpDecorator1 = new HTTPComponent();
+ httpDecorator1.setMatchingTag("component");
+ httpDecorator1.setMatchingValue("okhttp");
+ builtin.add(httpDecorator1);
+ }
+ {
+ final HTTPComponent httpDecorator2 = new HTTPComponent();
+ httpDecorator2.setMatchingTag("component");
+ httpDecorator2.setMatchingValue("java-aws-sdk");
+ builtin.add(httpDecorator2);
+ }
+ builtin.add(new ErrorFlag());
+ builtin.add(new DBTypeDecorator());
+ builtin.add(new DBStatementAsResourceName());
+ builtin.add(new OperationDecorator());
+ builtin.add(new Status404Decorator());
+ builtin.add(new URLAsResourceName());
+
+ return builtin;
+ }
}

Move default decorators to code