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

This commit is contained in:
renaudboutet 2017-05-24 13:44:35 +02:00
parent ee9e0626df
commit 3f7d852a65
4 changed files with 92 additions and 118 deletions

View File

@ -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
# 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

View File

@ -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);

View File

@ -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
# 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

View File

@ -5,9 +5,5 @@ writer:
port: 10000
sampler:
type: AllSampler
decorators:
- type: HTTP
componentName: hello
desiredServiceName: world