adding a logger conf
MODIFY
pom.xml
pom.xml
<artifactId>opentracing-api</artifactId>
<version>0.21.0</version>
</dependency>
-
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.8</version>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.25</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>net.logstash.logback</groupId>
+ <artifactId>logstash-logback-encoder</artifactId>
+ <version>4.9</version>
+ </dependency>
+
<!-- Testing dependencies -->
<dependency>
<groupId>junit</groupId>

ADD
src/main/java/com/datadoghq/trace/Utils/TracerLogger.java
+package com.datadoghq.trace.Utils;
+
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TracerLogger {
+
+ private Logger logger = LoggerFactory.getLogger("com.datadoghq.trace");
+
+ private final String startNewSpan = "Starting new span - %s [%s]";
+
+ public void startNewSpan(String operationName, long spanId) {
+
+ if (!logger.isTraceEnabled()) return;
+ logger.trace(String.format(startNewSpan, operationName, String.valueOf(spanId)));
+ }
+
+}

MODIFY
src/main/java/com/datadoghq/trace/impl/Tracer.java
src/main/java/com/datadoghq/trace/impl/Tracer.java
package com.datadoghq.trace.impl;
-import io.opentracing.References;
+import com.datadoghq.trace.Utils.TracerLogger;
import io.opentracing.Span;
import io.opentracing.SpanContext;
import io.opentracing.propagation.Format;
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.*;
public class Tracer implements io.opentracing.Tracer {
+ private TracerLogger logger = new TracerLogger();
+
public SpanBuilder buildSpan(String operationName) {
return new SpanBuilder(operationName);
}
@@ -99,6 +100,7 @@ public class Tracer implements io.opentracing.Tracer {
// build the context
DDSpanContext context = buildTheSpanContext();
+ logger.startNewSpan(this.operationName, context.getSpanId());
return new DDSpan(
Tracer.this,

ADD
src/main/resources/logback.xml
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+
+ <property name="log_directory" value="logs/"/>
+
+ <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+ <layout class="ch.qos.logback.classic.PatternLayout">
+ <Pattern>
+ %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
+ </Pattern>
+ </layout>
+ </appender>
+
+ <appender name="file-json" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${log_directory}/dd-tracer-json.log</file>
+ <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <fileNamePattern>
+ ${log_directory}/dd-tracer-json.%d{yyyy-MM-dd}.%i.log
+ </fileNamePattern>
+ <timeBasedFileNamingAndTriggeringPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+ <maxFileSize>10MB</maxFileSize>
+ </timeBasedFileNamingAndTriggeringPolicy>
+ </rollingPolicy>
+ </appender>
+
+ <appender name="console-json" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
+ </appender>
+
+ <logger name="com.datadoghq.trace" level="trace">
+ <appender-ref ref="console"/>
+ <appender-ref ref="file-json"/>
+ </logger>
+
+ <root level="info">
+ <appender-ref ref="console"/>
+ </root>
+
+</configuration>
\ No newline at end of file

RENAME
src/main/java/com/datadoghq/trace/Example.java
src/test/java/Example.java
-package com.datadoghq.trace;
-
-
+import com.datadoghq.trace.Writer;
import com.datadoghq.trace.impl.Tracer;
import com.datadoghq.trace.writer.impl.DDAgentWriter;
import io.opentracing.Span;

adding a logger conf