First version of the agent documentation

This commit is contained in:
renaudboutet 2017-05-24 13:31:24 +02:00
parent b880e29ab9
commit ee9e0626df
11 changed files with 26 additions and 47 deletions

View File

@ -23,21 +23,17 @@ sampler:
# Decorators are used to add extra information to span # Decorators are used to add extra information to span
# Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator # Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator
decorators: decorators:
# This span decorator leverages HTTP tags such as the URL requested - type: HTTP
- type: HTTPServiceDecorator
componentName: java-web-servlet componentName: java-web-servlet
- type: HTTP
# Decorator fot the HTTP client
- type: HTTPServiceDecorator
componentName: java-okhttp componentName: java-okhttp
desiredServiceName: http-client desiredServiceName: http-client
- type: DB
# This span decorator leverages DB tags such as the statement requested
- type: DBServiceDecorator
componentName: java-mongo componentName: java-mongo
desiredServiceName: mongo desiredServiceName: mongo
- type: DB
# Decorator for the AWS SDK client componentName: java-jdbc
- type: HTTPServiceDecorator desiredServiceName: jdbc
- type: HTTP
componentName: java-aws-sdk componentName: java-aws-sdk
desiredServiceName: aws-client desiredServiceName: aws-client

View File

@ -8,18 +8,18 @@ import io.opentracing.tag.Tags;
* This span decorator leverages DB tags. It allows the dev to define a custom * This span decorator leverages DB tags. It allows the dev to define a custom
* service name and retrieves some DB meta such as the statement * service name and retrieves some DB meta such as the statement
*/ */
public class DBServiceDecorator implements DDSpanContextDecorator { public class DB implements DDSpanContextDecorator {
protected final String componentName; protected final String componentName;
protected final String desiredServiceName; protected final String desiredServiceName;
public DBServiceDecorator(String componentName) { public DB(String componentName) {
super(); super();
this.componentName = componentName; this.componentName = componentName;
this.desiredServiceName = null; this.desiredServiceName = null;
} }
public DBServiceDecorator(String componentName,String desiredServiceName) { public DB(String componentName,String desiredServiceName) {
super(); super();
this.componentName = componentName; this.componentName = componentName;
this.desiredServiceName = desiredServiceName; this.desiredServiceName = desiredServiceName;

View File

@ -12,18 +12,18 @@ import io.opentracing.tag.Tags;
* This span decorator leverages HTTP tags. It allows the dev to define a custom * This span decorator leverages HTTP tags. It allows the dev to define a custom
* service name and retrieves some HTTP meta such as the request path * service name and retrieves some HTTP meta such as the request path
*/ */
public class HTTPServiceDecorator implements DDSpanContextDecorator { public class HTTP implements DDSpanContextDecorator {
protected final String componentName; protected final String componentName;
protected final String desiredServiceName; protected final String desiredServiceName;
public HTTPServiceDecorator(String componentName) { public HTTP(String componentName) {
super(); super();
this.componentName = componentName; this.componentName = componentName;
this.desiredServiceName = null; this.desiredServiceName = null;
} }
public HTTPServiceDecorator(String componentName,String desiredServiceName) { public HTTP(String componentName,String desiredServiceName) {
super(); super();
this.componentName = componentName; this.componentName = componentName;
this.desiredServiceName = desiredServiceName; this.desiredServiceName = desiredServiceName;

View File

@ -10,9 +10,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.datadoghq.trace.DDTracer; import com.datadoghq.trace.DDTracer;
import com.datadoghq.trace.integration.DBServiceDecorator; import com.datadoghq.trace.integration.DB;
import com.datadoghq.trace.integration.DDSpanContextDecorator; import com.datadoghq.trace.integration.DDSpanContextDecorator;
import com.datadoghq.trace.integration.HTTPServiceDecorator; import com.datadoghq.trace.integration.HTTP;
import com.datadoghq.trace.sampling.AllSampler; import com.datadoghq.trace.sampling.AllSampler;
import com.datadoghq.trace.sampling.RateSampler; import com.datadoghq.trace.sampling.RateSampler;
import com.datadoghq.trace.sampling.Sampler; import com.datadoghq.trace.sampling.Sampler;
@ -88,11 +88,11 @@ public class DDTracerResolver extends TracerResolver {
String componentName = (String) map.get("componentName"); String componentName = (String) map.get("componentName");
String desiredServiceName = (String) map.get("desiredServiceName"); String desiredServiceName = (String) map.get("desiredServiceName");
if (map.get("type").equals(HTTPServiceDecorator.class.getSimpleName())) { if (map.get("type").equals(HTTP.class.getSimpleName())) {
decorator = new HTTPServiceDecorator(componentName, desiredServiceName); decorator = new HTTP(componentName, desiredServiceName);
tracer.addDecorator(decorator); tracer.addDecorator(decorator);
} else if (map.get("type").equals(DBServiceDecorator.class.getSimpleName())) { } else if (map.get("type").equals(DB.class.getSimpleName())) {
decorator = new DBServiceDecorator(componentName, desiredServiceName); decorator = new DB(componentName, desiredServiceName);
tracer.addDecorator(decorator); tracer.addDecorator(decorator);
} }
} }

View File

@ -24,11 +24,10 @@ sampler:
# Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator # Could be DBServiceDecorator, MapperDecorator or HTTPServiceDecorator
decorators: decorators:
# This span decorator leverages HTTP tags such as the URL requested # This span decorator leverages HTTP tags such as the URL requested
- type: HTTPServiceDecorator - type: HTTP
componentName: http componentName: http
desiredServiceName: unnamed-java-http desiredServiceName: unnamed-java-http
# This span decorator leverages DB tags such as the statement requested # This span decorator leverages DB tags such as the statement requested
- type: DBServiceDecorator - type: DB
componentName: db componentName: db
desiredServiceName: unnamed-java-db desiredServiceName: unnamed-java-db

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<root level="trace">
<appender-ref ref="console"/>
</root>
</configuration>

View File

@ -8,7 +8,7 @@ import org.junit.Test;
import com.datadoghq.trace.DDTracer; import com.datadoghq.trace.DDTracer;
import com.datadoghq.trace.integration.DDSpanContextDecorator; import com.datadoghq.trace.integration.DDSpanContextDecorator;
import com.datadoghq.trace.integration.HTTPServiceDecorator; import com.datadoghq.trace.integration.HTTP;
public class TracerResolverTest { public class TracerResolverTest {
@ -21,8 +21,8 @@ public class TracerResolverTest {
assertThat(decorators.size()).isEqualTo(1); assertThat(decorators.size()).isEqualTo(1);
DDSpanContextDecorator decorator = decorators.get(0); DDSpanContextDecorator decorator = decorators.get(0);
assertThat(decorator.getClass()).isEqualTo(HTTPServiceDecorator.class); assertThat(decorator.getClass()).isEqualTo(HTTP.class);
HTTPServiceDecorator httpServiceDecorator = (HTTPServiceDecorator) decorator; HTTP httpServiceDecorator = (HTTP) decorator;
assertThat(httpServiceDecorator.getComponentName()).isEqualTo("hello"); assertThat(httpServiceDecorator.getComponentName()).isEqualTo("hello");
assertThat(httpServiceDecorator.getDesiredServiceName()).isEqualTo("world"); assertThat(httpServiceDecorator.getDesiredServiceName()).isEqualTo("world");
} }

View File

@ -6,7 +6,7 @@ writer:
sampler: sampler:
type: AllSampler type: AllSampler
decorators: decorators:
- type: HTTPServiceDecorator - type: HTTP
componentName: hello componentName: hello
desiredServiceName: world desiredServiceName: world

View File

@ -9,7 +9,7 @@
</layout> </layout>
</appender> </appender>
<root level="INFO"> <root level="trace">
<appender-ref ref="console"/> <appender-ref ref="console"/>
</root> </root>