Skip to content

Commit 228f896

Browse files
author
Andrew Kent
committed
Move default decorators to code
1 parent 13b0df8 commit 228f896

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Decorators are used to add extra information to span.
2+
# To modify, copy the file to dd-trace-decorators.yaml and make desired changes.
3+
# Could be DBServiceDecorator or HTTPServiceDecorator, etc.
4+
decorators:
5+
- type: HTTPComponent
6+
matchingTag: component
7+
matchingValue: okhttp
8+
- type: HTTPComponent
9+
matchingTag: component
10+
matchingValue: java-aws-sdk
11+
- type: ErrorFlag
12+
- type: DBTypeDecorator
13+
- type: DBStatementAsResourceName
14+
- type: OperationDecorator
15+
- type: Status404Decorator
16+
- type: URLAsResourceName

dd-trace-ot/src/main/java/datadog/opentracing/decorators/DDDecoratorsFactory.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,38 @@ public static List<AbstractDecorator> create(
6868
}
6969

7070
public static List<AbstractDecorator> createFromResources() {
71-
List<AbstractDecorator> result = new ArrayList<>();
71+
final List<AbstractDecorator> result;
7272
final DecoratorsConfig config =
7373
ConfigUtils.loadConfigFromResource(CONFIG_PATH, DecoratorsConfig.class);
74-
if (config != null) {
74+
if (config == null) {
75+
result = createBuiltinDecorators();
76+
} else {
7577
result = DDDecoratorsFactory.create(config.getDecorators());
7678
}
7779
return result;
7880
}
81+
82+
private static List<AbstractDecorator> createBuiltinDecorators() {
83+
List<AbstractDecorator> builtin = new ArrayList<AbstractDecorator>(8);
84+
{
85+
final HTTPComponent httpDecorator1 = new HTTPComponent();
86+
httpDecorator1.setMatchingTag("component");
87+
httpDecorator1.setMatchingValue("okhttp");
88+
builtin.add(httpDecorator1);
89+
}
90+
{
91+
final HTTPComponent httpDecorator2 = new HTTPComponent();
92+
httpDecorator2.setMatchingTag("component");
93+
httpDecorator2.setMatchingValue("java-aws-sdk");
94+
builtin.add(httpDecorator2);
95+
}
96+
builtin.add(new ErrorFlag());
97+
builtin.add(new DBTypeDecorator());
98+
builtin.add(new DBStatementAsResourceName());
99+
builtin.add(new OperationDecorator());
100+
builtin.add(new Status404Decorator());
101+
builtin.add(new URLAsResourceName());
102+
103+
return builtin;
104+
}
79105
}

0 commit comments

Comments
 (0)