Fixed serialization and send to DDagent
MODIFY
src/main/java/com/datadoghq/trace/impl/DDSpan.java
src/main/java/com/datadoghq/trace/impl/DDSpan.java
package com.datadoghq.trace.impl;
+import java.util.Map;
+
import com.fasterxml.jackson.annotation.JsonGetter;
+
import io.opentracing.Span;
import io.opentracing.SpanContext;
-import java.util.Map;
-import java.util.Optional;
-
public class DDSpan implements io.opentracing.Span {
@@ -14,6 +14,7 @@ public class DDSpan implements io.opentracing.Span {
protected String operationName;
protected Map<String, Object> tags;
protected long startTime;
+ protected long startTimeNano; // Only used to measure nano time durations
protected long durationNano;
protected final DDSpanContext context;
@@ -26,7 +27,8 @@ public class DDSpan implements io.opentracing.Span {
this.tracer = tracer;
this.operationName = operationName;
this.tags = tags;
- this.startTime = Optional.ofNullable(timestamp).orElse(System.nanoTime());
+ this.startTime = System.currentTimeMillis()*1000000;
+ this.startTimeNano = System.nanoTime();
this.context = context;
}
@@ -35,15 +37,11 @@ public class DDSpan implements io.opentracing.Span {
}
public void finish() {
- this.durationNano = System.nanoTime() - startTime;
- }
-
- public void finishWithDuration(long durationNano) {
- this.durationNano = durationNano;
+ this.durationNano = System.nanoTime() - startTimeNano;
}
- public void finish(long stopTime) {
- this.durationNano = startTime - stopTime;
+ public void finish(long stopTimeMicro) {
+ this.durationNano = stopTimeMicro * 1000L - startTime;
}
public void close() {

MODIFY
src/main/java/com/datadoghq/trace/writer/impl/DDApi.java
src/main/java/com/datadoghq/trace/writer/impl/DDApi.java
@@ -119,8 +119,8 @@ public class DDApi {
DDApi api = new DDApi(DDAgentWriter.DEFAULT_HOSTNAME, DDAgentWriter.DEFAULT_PORT);
- String service = "{\"service_name\": {\"app\": \"service-name\",\"app_type\": \"web\"}}";
- System.out.println("Pushed service: "+api.callPUT(api.servicesEndpoint, service));
+// String service = "{\"service_name\": {\"app\": \"service-name\",\"app_type\": \"web\"}}";
+// System.out.println("Pushed service: "+api.callPUT(api.servicesEndpoint, service));
System.out.println("Pushed traces: "+api.sendTraces(traces));
}

Fixed serialization and send to DDagent